DNS for a static website on AWS S3
Setup S3 Buckets
#First I had to setup static website s3 buckets.
Anywhere you see edthe.dev and www.edthe.dev, substitute your own apex domain name (i.e. yourdomainname.com) and your www. subdomain (i.e. www.yourdomainname.com).
Serve a static website from an S3 Bucket
#Do a bunch of non-repetivite stuff manually in the AWS Web Console:
-
Point my domain registrar NameSevers for
edthe.devto the name servers listed in my Route53 hosted zone foredthe.dev.ns-number.awsdns-number.com. ns-number.awsdns-number.org. ns-number.awsdns-number.co.uk. ns-number.awsdns-number.net. -
Request an SSL Certificate in
AWS Certificate Managerthat coversedthe.devandwww.edthe.dev.- Be sure to choos
Validaton Method: DNS validation - Accept the default
Key algorithm
- Be sure to choos
-
Do the DNS Domain Ownership verification dance.
- The easiest way to do this is to ignore the detailed guide and instead click into the pending request in
Certificate Manager - Certificatesand scroll down. There should be a button that basially saysAdd DNS Records to Route 53 for me. I typically push that button, and go grab a coffee.
Tip: Do not remove the certificate ownership DNS records. I have heard it is helpful to still have when the SSL Certificate needs renewed.
- The easiest way to do this is to ignore the detailed guide and instead click into the pending request in
-
Create 2 CloudFront instances, one for
edthe.devand one forwww.edthe.dev.- Select
edthe.devorwww.edthe.devfor theOrigin Domain. You will do this twice, once for each of your apex domain, and yourwww.sub-domain. - Leave any option not mentioned here with the default values.
- Under
Viewer Protocol Policy, selectRedirect HTTP to HTTPS. - Under
Web Application Firewall (WAF)chooseDo not enable security protections. A static website is immune to the attacks that a WAF protects against. - Be sure to assign each CloudFront instance the appropriate
alternate domain name (CNAME)i.e.www.edthe.dev.
Tip:
alternate domainis incredibly hard to find, but critical. Scroll back and forth up the page until you find it.- Under
Custom SSL Cetificate - optional, choose the SSL Certificate you requested earlier. It should be the only option in the list.
Tip: If your SSL Certificate is not yet available, double check the steps above, and then just take a 20 minute coffee break.
- Select
-
Assign each CloudFront instance the SSL Certificate.
-
Add A and AAAA records for
www.edthe.devpointing to thewww.edthe.devCloudFront distribution.www.edthe.dev A Simple - 1stbunchofletters.cloudfront.net. www.edthe.dev AAAAA Simple - 1stbunchofletters.cloudfront.net.Tip - the same
(bunch of letters).cloudfront.netgoes in both of these DNS record'svaluefield. -
Add A and AAAA records for
edthe.devpointing to theedthe.devCloudFront (CDN) distribution.edthe.dev A Simple - 2ndbunchofletters.cloudfront.net. edthe.dev A Simple - 2ndbunchofletters.cloudfront.net.Tip - the same
(bunch of letters).cloudfront.netgoes in both of these DNS record'svaluefield, as each-other, but the value is different than thevaluein the previous step forwww.. This is because theCDNforedthe.devand theCDNforwww.edthe.devare different.
Related Tasks
#Now my site exists, but I still need a way to modify my AWS S3 Bucket contents.
When it was time to set this up a second time for the domain I share with my spouse, I decided it would be wise to delegate access to manage AWS Route 53 DNS to my spouse.