This is a note to self of setup steps when purchasing a new domain on Namecheap, pointing its DNS to Route 53, requesting an SSL certificate, and setting up a CloudFront distribution for it to point to an S3 bucket.
Create a new hosted zone for the new domain in Route 53. Will be given the correct nameservers to use under record type 'NS'. Add these values in NameCheap under 'Custom DNS'.
https://console.aws.amazon.com/acm/
Choose verification through DNS, and click the button which uses Route 53 to automatically create the correct CNAME record in order to verify. (There will be three records in your Route 53 Hosted Zone at this point - 'NS', 'CNAME', and 'SOA'
Use the certificate from the previous step.
Note that an existing S3 bucket cannot be renamed.
Note to self - the simple version of the S3 URL doesn't seem to work, need to use the long one with region name
https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-serve-static-website/
Note that CloudFront change take a few minutes to propagate.
i.e. this is what points f52grsyi0jhgfi.cloudfront.net (Domain Name) to example.com.s3-website-us-east-1.amazonaws.com (Origin)
This is what points example.com to f52grsyi0jhgfi.cloudfront.net.
https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html
When done there will be 5 or 7 records in the Route 53 Hosted Zone (can do just IPv4, or IPv4 and IPv6). To recap what they are used for:
- SOA
- CNAME (from certificate setup)
- NS (Route 53 nameservers, used for Namecheap Custom DNS)
- A: IPv4: example.com -> alias, point to cloudfront domain
- A: IPv4: www.example.com -> alias, point to cloudfront domain
- A: IPv6: example.com -> alias, point to cloudfront domain
- A: IPv6: www.example.com -> alias, point to cloudfront domain