Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Crib sheet: set up a static website on AWS S3

Crib sheet: set up a static website on AWS S3

A useful walkthrough is also available on

Set up S3 buckets and configure them for web hosting

  1. Open the AWS console and choose s3 link
  2. Create a new bucket, naming it exactly as your domain name e.g.
  3. Open the Permissions settings and click "Edit bucket policy", setting the value to a policy as follows (remember to swap in your bucket name):
	"Version": "2012-10-17",
	"Statement": [
			"Sid": "AddPerm",
			"Effect": "Allow",
			"Principal": "*",
			"Action": "s3:GetObject",
			"Resource": "*"
  1. Set the "Static Website Hosting" option for this bucket to "Enable website hosting", setting the Index Document to index.html (or the index document of your choice)
  2. Create a new bucket, nameing it exactly as the first bucket, but with www. preceding the name e.g. `
  3. Set the "Static Website Hosting" option for this bucket to "Redirect all requests to another host name and set the redirection destination to your domain name e.g.
  4. Upload your site's files to the first bucket (without the www), or simply upload a dummy index.html file. Visit the bucket's endpoint (you can find it under the "Static Website Hosting" section for the bucket. The site's content should now be accessible over the public web.

Point your domain to Amazon's Route 53 service

  1. Go to AWS Route53 in the AWS console link
  2. Create a new Hosted zone for your domain name
  3. Create a record set for the naked domain and the www. alias, pointing at the respective S3 buckets
  4. Create record sets as appropriate depending on your existing DNS setup
  5. Set your domain's DNS Servers to be the ones provided by AWS (find them on the "Hosted Zone" entry you just created
  6. Check the domain is pointing properly to the s3 bucket by visiting the URL in a browser. You may need to use, the dig command line tool, clear your caches, or even use a VPN to see that the updates have taken effect.

Set up an IAM user on AWS for this project

  1. Go to AWS IAM console link
  2. Create new IAM user
  3. Take a note of the Access Key ID and Secret Access Key
  4. Attach a policy to the user, selecting AmazonS3FullAccess (you could narrow down the policy to allow access to your specific buckets only)

Set up automated git deployment with Codeship

  1. Go to Codeship and create a new project. Link your Github repo as normal.
  2. Save the project with no testing pipeline configured (unless you want to run tests, of course)
  3. Click "Project Settings", then "Deployment".
  4. Set up a new Deployment Pipeline for the master branch and choose Amazon S3 as the deployment method
  5. Fill in the AWS access key ID and secret access key fields with the IAM user's keys from the previous section. Select the same region as your buckets are in, set the S3 bucket name (e.g., set the local path to ./ and set the ACL according to the policy you attached to the IAM user (e.g. bucket-owner-full-control
  6. Attempt a deploy and see if it worked!

This comment has been minimized.

Copy link

grpaiva commented Feb 6, 2019

You just saved my life. Was struggling with this local path for hours. I've tried / and Codeship uploaded the whole VM to my S3 bucket (more than 3gb). Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.