How to set up a root domain (non-www) in AWS Route 53
From the Strattic dashboard, click the Details button, then click the Domain menu item, input your domain (without the www) and click continue.
You’ll see a CNAME like this to validate the SSL certificate for the root domain.
Log in to your AWS console and navigate to Route 53.
Create a new hosted zone for your domain or use an existing hosted zone.
Add the CNAME to validate SSL (within domain hosting zone).
Please wait up to 30 minutes for this verification process to complete.
Click “Continue” in the Strattic Dashboard.
You’ll see a CNAME like this:
Add the record as an Alias A record to Cloudfront. Hint: just paste in the CloudFront value.
How to set up a redirect from www to root
(eg: www.example.com to example.com)
This will include:
Welcome to your little AWS crash course! Don’t worry, it isn’t as scary as it looks 😉
Creating the s3 bucket
Navigate to s3 in your AWS console.
Create a new bucket with the name of your domain (eg: www.example.com) in region us-east-1. Make sure Block all public access is unchecked and click Save.
We’ll set up the redirect using the S3 static web hosting feature.
Navigate to the s3 bucket just created and select properties. Find the static web hosting section and Click on Edit.
Enable static web hosting, with type Redirects. The host name should be your root domain (eg: example.com), and the protocol should be set to https. Then hit Save Changes.
You can now test the redirection by clicking the link shown. Copy this link and save it somewhere, as we’re going to need it later on.
Creating the SSL Certificate for the www domain
Open up AWS Certificate Manager and click the request a certificate (you can also import a custom certificate). Then select “Request a public certificate” and click “Request a Certificate”.
Enter your domain name including the www and click Next.
Select DNS Validation and click Next. On the next screen you can choose to add a tag, and then click Review. Once you review that everything is correct, click Confirm and Request.
Your new certificate will now have the status of Pending Validation. In order for the certificate to be issued, you will need to add the CNAME record provided to your hosting zone in Route 53.
After adding that CNAME it may take some time to propagate, but once the certificate status has updated to Issued, we can move on to creating the Cloudfront Distribution.
Create the Cloudfront distribution for the redirect
Open up Cloudfront in your AWS console and click on Create Distribution, then click Get started.
Under Origin Domain Name, you will need to add the domain for your static site that we saved earlier. The Origin ID will be populated automatically.
For Viewer protocol policy, select “Redirect HTTP to HTTPS”.
Add your domain name including the www under Alternate Domain Names.
For the SSL certificate, select “Custom SSL certificate”, and choose the one that was just created for your domain from the dropdown.
All other settings can be left as the default, and you can go ahead and click on Create Distribution.
You can now add the final CNAME record in Route 53 for your www domain, which points to the new Cloudfront distribution domain. Your final Route 53 records should look something like this.
And that’s it! You’ll receive your AWS certificate in the post! 🙃