Skip to content

Instantly share code, notes, and snippets.

@sometimescasey
Last active June 24, 2020 14:06
Show Gist options
  • Save sometimescasey/40bcbc383783d8772e7538e0c1c16eb9 to your computer and use it in GitHub Desktop.
Save sometimescasey/40bcbc383783d8772e7538e0c1c16eb9 to your computer and use it in GitHub Desktop.
AWS - Route 53, CloudFront, and certificate

Note

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.

1. Point NameCheap domain Custom DNS to Route 53

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'.

2. Request new SSL certificate for example.com and *.example.com

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'

3. Make new CloudFront distribution for S3 bucket

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)

4. Add 'A' records in Route 53 for the CloudFront distribution

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment