Now that we have our domain and a certificate to serve it over HTTPS, let’s associate these with our CloudFront Distribution
Add Alternate Domain for CloudFront Distribution
Head over to the details of your CloudFront Distribution and hit Edit.
And type in your new domain name in the Alternate Domain Names (CNAMEs) field.
Now switch the SSL Certificate to Custom SSL Certificate and select the certificate we just created from the drop down. And scroll down to the bottom and hit Yes, Edit.
Scroll down and hit Yes, Edit to save the changes.
Next, head over to the Behaviors tab from the top.
And select the only one we have and hit Edit.
Then switch the Viewer Protocol Policy to Redirect HTTP to HTTPS. And scroll down to the bottom and hit Yes, Edit.
Next, let’s point our domain to the CloudFront Distribution.
Point Domain to CloudFront Distribution
Head back into Route 53 and hit the Hosted Zones button. If you don’t have an existing Hosted Zone, you’ll need to create one by adding the Domain Name and selecting Public Hosted Zone as the Type.
Select your domain from the list and hit Create Record Set in the details screen.
Leave the Name field empty since we are going to point our bare domain (without the www.) to our CloudFront Distribution.
And select Alias as Yes since we are going to simply point this to our CloudFront domain.
In the Alias Target dropdown, select your CloudFront Distribution.
Finally, hit Create to add your new record set.
Add IPv6 Support
CloudFront Distributions have IPv6 enabled by default and this means that we need to create an AAAA record as well. It is set up exactly the same way as the Alias record.
Create a new Record Set with the exact settings as before, except make sure to pick AAAA - IPv6 address as the Type.
And hit Create to add your AAAA record set.
It can take around an hour to update the DNS records but once it’s done, you should be able to access your app through your domain.
Next up, we’ll take a quick look at ensuring that our www. domain also directs to our app.