Last week, Amazon added support for using second level domains for static websites hosted on S3. The instructions in Amazon’s blog post misled me, and it sounds like Dave Winer was similarly confused. To clarify, their instructions describe how to redirect a second level domain to any other domain. What I actually want, and what the new feature also enables is serving my website content directly from my second level domain. Here are the steps to do that instead:
Create an S3 bucket for your second level domain, e.g.,
Enable website hosting, and enter an index document name, e.g.,
Add a bucket policy. Copy, paste, and edit the sample policy, replacing
example-bucketwith the name of your second level domain bucket.
Upload your website content to your second level domain bucket.
Create an A “Alias” DNS record in Route 53. Name it the same as your second level domain name, e.g.
matthewlmcclure.com, and select the S3 website endpoint corresponding to your second level domain from the menu that appears when you click the Alias Target field. This is the key step that enables the new feature. A “Alias” records appear as though they are normal A records to resolvers, and Route 53 directs requests to your S3 bucket.
- If you previously hosted the same content on a subdomain, e.g.,
static.matthewlmcclure.com, redirect requests for the subdomain to your second level domain. In the bucket properties for your subdomain, select Redirect All Requests to Another Host Name and enter your second level domain in the Redirect All Requests To field.
The instructions in Amazon’s S3 developer guide should produce the same results, but the steps in Amazon’s blog post would do the opposite.