Skip to content

Instantly share code, notes, and snippets.

@bdiegel
Last active April 12, 2016 21:59
Show Gist options
  • Save bdiegel/85426beb9d7e2b8c3d5b to your computer and use it in GitHub Desktop.
Save bdiegel/85426beb9d7e2b8c3d5b to your computer and use it in GitHub Desktop.

Host a static web site on S3:

Walkthrough on AWS Docs

Instructions

Instructions using the web console to create a bucket to host a static web site with a custom domain.

  • Create a Bucket: Click ‘Create a Bucket’. Name your bucket the same name as your custom domain: www.example.com
  • Enable static serving:
    • click on 'Properties’ for your bucket
    • click 'Static Website Hosting’
    • click 'Enable website hosting’
      • specify and index document (index.html) and error document
  • Upload Files:
    • double click on your new bucket
    • click 'Upload’
    • drag and drop all your static files (html/css/js)
  • Set Files to Public:
    • click 'Set Permissions’
    • add the bucket policy
  • Set up DNS: (go to your DNS provider)
  • Done: Go to www.example.com and it will serve your static content. You can also go to example.com and it’ll work as well.

Example Bucket Policy

See also: policy generator tool

  {
    //"Version": "2008-10-17",
    "Version":"2012-10-17",
    "Statement": [{
      "Sid": "AllowPublicRead",
      "Effect": "Allow",
      "Principal": { "AWS": "*" },
      "Action": ["s3:GetObject"],
      "Resource": ["arn:aws:s3:::www.example.com/*" ]
    }]
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment