Custom Domains with Route 53
Route 53 is AWS's DNS service — it points your domain name at CloudFront or a load balancer.
Route 53 is AWS's DNS (Domain Name System) service. DNS translates a human name like example.com into the address of your infrastructure.
Key concepts
- Hosted zone — a container for all DNS records of one domain.
- A / AAAA record — maps a name to an IPv4 / IPv6 address.
- Alias record — an AWS-specific record that points a name directly at a CloudFront distribution, load balancer, or S3 site with no extra cost.
Wiring a site together
For a CloudFront-served site you create an Alias A record for www.example.com that targets the distribution. Requests to your domain now flow to CloudFront, which serves cached files from S3.
Example
{
"Comment": "Point www at CloudFront",
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "www.example.com",
"Type": "A",
"AliasTarget": {
"HostedZoneId": "Z2FDTNDATAQYW2",
"DNSName": "d123abc.cloudfront.net",
"EvaluateTargetHealth": false
}
}
}]
}When to use it
- A team points their apex domain (example.com) at CloudFront using a Route 53 alias record so there is no extra hop.
- An organisation uses Route 53 health checks to automatically fail over DNS to a backup region when the primary goes down.
- A developer adds a CNAME in Route 53 to validate an ACM certificate as part of automating HTTPS setup.
More examples
Create a hosted zone for a domain
Creates a Route 53 public hosted zone for the domain, giving you a set of nameservers to point to.
aws route53 create-hosted-zone \
--name example.com \
--caller-reference $(date +%s)Alias record pointing to CloudFront
Creates an alias A record at the apex domain pointing to CloudFront — alias records are free and resolve faster than CNAMEs.
{
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "example.com",
"Type": "A",
"AliasTarget": {
"HostedZoneId": "Z2FDTNDATAQYW2",
"DNSName": "d111111abcdef8.cloudfront.net",
"EvaluateTargetHealth": false
}
}
}]
}Apply change batch to hosted zone
Submits the alias record change batch to Route 53 to route the domain to the CloudFront distribution.
aws route53 change-resource-record-sets \
--hosted-zone-id Z1234567890ABC \
--change-batch file://alias-record.json
Discussion