Cloud / AWS / DNS
Amazon Route 53
Give your website a memorable domain name, then use DNS records to send visitors to the CloudFront distribution you already created.
What Route 53 does
Amazon Route 53 is AWS’s DNS service. DNS (Domain Name System) helps a browser find the service for a name such as www.example.com. Route 53 stores DNS records and answers lookups; CloudFront still delivers your site’s files.
Route 53 can also register domain names, but domain registration and DNS hosting are separate jobs. You can buy a domain through Route 53 or another registrar, then use Route 53 to host its DNS records. AWS: route a domain to a CloudFront distribution.
Three terms to know
- Domain: the name you register, such as
example.com. - Hosted zone: the set of DNS settings for a domain. A public hosted zone answers internet lookups; a private hosted zone answers lookups from selected VPCs inside AWS.
- Record: one instruction for a name, such as where
www.example.comshould go.
When a domain is registered with Route 53, AWS creates a matching hosted zone. If the domain is registered elsewhere, you can create a Route 53 public hosted zone and update the registrar’s name server settings to point to it. A hosted zone by itself does not register a domain. AWS: route traffic with hosted zones and records.
Records you will see
- A: maps a name to an IPv4 address.
- AAAA: maps a name to an IPv6 address.
- CNAME: points a subdomain, such as
www.example.com, to another domain name. A CNAME cannot be used at the root nameexample.com. - Alias: a Route 53 feature that can point a name—including the root domain—to supported AWS services such as CloudFront. For a CloudFront distribution, use an A alias record, and add an AAAA alias too if IPv6 is enabled.
- TXT: stores text used for things such as domain ownership checks.
For this lesson, the important one is the Route 53 Alias to CloudFront. It looks similar to a CNAME in purpose, but supports the root domain too. AWS: compare alias and non-alias records.
Before connecting your domain
Make sure you have these pieces ready:
- A domain name that you own and can manage. If you do not have one, you can register one, but check its current price and renewal cost before purchasing.
- A Route 53 public hosted zone for that domain. Use the existing zone if one is already set up; avoid creating a duplicate zone unless you plan to update the domain’s name servers to the new zone.
- A working CloudFront distribution. For your own domain to serve the site over HTTPS, first add the domain as a CloudFront alternate domain name and attach a matching TLS certificate. An ACM certificate used by CloudFront must be in
us-east-1(N. Virginia), even if your other AWS resources are in a different Region. AWS: CloudFront certificate requirements.
Step 1: Find your public hosted zone
- Open the Route 53 Hosted zones page.
- Find the zone whose name matches your domain, such as
example.com, and open it. - If your domain is registered with another company and no zone exists, choose Create hosted zone, enter your domain, and choose Public hosted zone. After creating it, copy the four name servers from its NS record and set those at your domain registrar. DNS will not use this new zone until the registrar delegates the domain to those name servers.
If you are only learning and do not own a domain yet, stop here and use a made-up example to follow the concepts. You cannot make a real public domain work without owning it and controlling its DNS.
Step 2: Add an Alias record for CloudFront
First, confirm that CloudFront is configured for the same domain name you plan to use. A DNS record alone cannot add a custom domain to a CloudFront distribution or create its HTTPS certificate.
- In the Route 53 hosted zone, choose Create record.
- For the root domain (for example,
example.com), leave Record name empty. To use a subdomain such aswww.example.com, enterwww. - Choose record type A, turn Alias on, and for the route target choose Alias to CloudFront distribution.
- Select your distribution, keep the default health evaluation setting, and choose Create records.
- If IPv6 is enabled for the CloudFront distribution, create a matching AAAA Alias record as well.
For a CloudFront Alias record to work, the distribution must have an alternate domain name that matches the record name. Follow the console labels if AWS has updated its layout. The full AWS procedure is in Route traffic to CloudFront with Route 53.
Step 3: Check the result
- Wait for the CloudFront distribution changes to finish deploying.
- Open your domain in a browser using
https://, for examplehttps://www.example.com. - If the page does not load, check that the record points to the right distribution, the distribution includes the exact same alternate domain name, the certificate covers that name, and the domain is delegated to the correct Route 53 name servers.
DNS answers can be cached, so changes may take time to appear everywhere. Route 53 says its changes generally propagate to its servers within about 60 seconds, but a visitor’s resolver may still have an older cached answer. AWS: CloudFront routing and propagation details.
Quick check
Suppose you want www.example.com to open your CloudFront website. Which Route 53 record do you create?
Show the answer
Create an A record with Alias turned on, then choose the CloudFront distribution. Add an AAAA Alias too if IPv6 is enabled. The distribution must already be configured to accept www.example.com and have a matching HTTPS certificate.
What comes next
You have learned the DNS part of connecting a custom domain to the S3 and CloudFront site. The next useful topic is AWS Certificate Manager (ACM), which provides the certificate CloudFront uses for HTTPS with your own domain.