Walkthrough on AWS Docs
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)
- create a 'CNAME’ that hits the www subdomain and sends to www.example.com.s3-website-us-east-1.amazonaws.com (if you set up on amazon’s us-east)
- also create a URL redirect from @ to www.example.com.
- 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.
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/*" ]
}]
}