Setup a custom domain on AWS using S3 static website hosting and Route 53

First, buy a domain name.

Once you have your domain, go to Route 53 in the AWS console and create a new Hosted Zone. Be aware that this costs $0.50/month.

Click into your record set. It’ll have an NS record. Click on that to find your name servers.

On your registrar (the company you bought the domain from), edit the name servers for the domain. Note that this whole process is easier if you use Amazon as your registrar. I used Hover.com, and the screenshot below is from Hover.

Next, go to S3 in the AWS console and setup your S3 buckets. You’ll need two, one for the plain domain, and one for www.domain. Name them exactly as the domain reads. So if you own vacuum-cleaners.com, your buckets will be vacuum-cleaners.com and www.vacuum-cleaners.com.

(I’m going to assume we’ll redirect www.domain.com requests to domain.com, simply because that’s what I prefer, but there’s some debate about this, so feel free to swap this and redirect to www. if you want.)

Go to Properties on your root domain (vacuum-cleaners.com) bucket. Set it up to have static hosting:

Next, go to Properties on your www.vacuum-cleaners.com domain. Set it up to redirect to your root domain:

The final step is to create two DNS “A” records back in Route 53 in your Hosted Zone:

There are a couple of confusing things about this process which I’ll talk about below the screenshot:

That should be it. Now if you upload an index.html to your root bucket (vacuum-cleaners.com S3 bucket), and navigate to vacuum-cleaners.com or www.vacuum-cleaners.com in a browser, you should see your HTML show up.

NOTE: it can take a few hours for DNS propagation to finish. A helpful tool to see if it’s finished or in progress is: https://dnschecker.org/#A/www.your-domain-here.com