If you are hosting content with a 3rd party provider that relies on a CNAME for using a custom domain (i.e. SquareSpace) and your domain is managed in Route 53 you will find you have an issue with your apex domain (the domain without the “www.” at the front, so for this website it would be “mikeapted.com”).
While some managed DNS providers (like DNSimple) allow you to create an ALIAS record at the apex, this is not an option in Route 53. You can setup an A record, which won’t work for sites like SquareSpace or you can set up an alias to another AWS resource.
This alias to another AWS resource is where we work around this issue. By creating an S3 bucket with site hosting enabled, and redirecting it to the “www.” version of the site we can effectively bump our apex domain traffic to the CNAME capable “www.” subdomain.
In detail the steps are:
- Create a CNAME record in Route 53 for your “www.” subdomain pointing at the appropriate hostname for your site, based on the 3rd party provider.
- Create an S3 bucket with the name of your apex domain (i.e. “mikeapted.com”).
- Under the Static Website Hosting tab for that bucket select the “Redirect all requests to another host name” option and enter your “www.” domain (i.e. “www.mikeapted.com”).
- In the Route 53 console add an A record for the apex domain and select “Yes” next to the Alias option.
- Under the Alias Target dropdown select your apex domain named bucket under “S3 Website Endpoints”
Your apex domain web traffic will now be redirected to the “www.” subdomain, which properly serves you your 3rd party hosted site through the CNAME.