How to Host a Website on S3 Without Getting Lost in the Sea

A Bit Of History

Source: https://regmedia.co.uk/2017/02/28/awsoutageboard.jpg

1. Naming Your S3 Bucket

2. Configuring Your S3 Bucket for Static Website Hosting

aws s3 website s3://www.my-awesome-site.com/ --index-document index.html --error-document error.html
{
"Version": "2008-10-17",
"Id": "PolicyForPublicWebsiteContent",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.my-awesome-site.com/*"
}
]
}
aws s3api put-bucket-policy --bucket www.my-awesome-site.com --policy file://policy.json

3. Adding A CNAME Record For Your Bucket Url

www.my-awesome-site.com CNAME www.my-awesome-site.com.s3-website-us-east-1.amazonaws.com

4. Uploading Your Static Website

about/
index.html
contact/
index.html
css/
styles.min.css
...
...
index.html
The AWS S3 Console
aws s3 cp personal-blog/src/_site/ s3://www.my-awesome-site.com/ --recursive

5. Validate That It Worked

Benefits

Conclusion

Learn AWS By Actually Using It

If you enjoyed this, don’t forget to hit that green ❤ to show your support!

Software Engineer. Entrepreneur. Love traveling and experiencing life. https://www.kylegalbraith.com/learn-aws/