a small lesson learned in setting up a static web site with S3 and CloudFront
I created a static web site hosted in an S3 bucket named
www.example.com
(not the real name) and enabled accessing it as a
website. I wanted delivery to be fast to everybody around the world,
so I created a CloudFront distribution in front of the S3 bucket.
I wanted S3 to automatically add “index.html” to URLs ending in a
slash (CloudFront can’t do this), so I configured the CloudFront
distribution to access the S3 bucket as a web site using
www.example.com.s3-website-us-east-1.amazonaws.com
as the origin
server.
Before sending all of the www.example.com
traffic to the new setup,
I wanted to test it, so I added test.example.com
to the list of
CNAMEs in the CloudFront distribution.
After setting up Route53 so that DNS lookups for test.example.com
would resolve to the new CloudFront endpoint, I loaded it in my
browser and got the following error: