CNAME vs alias
How a CNAME and a Route 53 alias record differ, why alias works at the zone apex, and which AWS resources an alias can point to.
The problem
AWS resources such as load balancers and CloudFront distributions come with an AWS hostname, like lb1-1234.us-east-2.elb.amazonaws.com. Users should see a custom name instead, like myapp.mydomain.com, or just mydomain.com. There are two ways to point the custom name at the AWS one.
CNAME
- Points a name to any other name:
app.mydomain.com→blabla.anything.com. - Only for names below the apex, such as
something.mydomain.com. Standard DNS doesn't allow a CNAME at the zone apex. - The TTL is set on the record, and Route 53 charges for the queries.
Alias records
An alias record is a Route 53 extension to DNS that points a name to an AWS resource: app.mydomain.com → blabla.amazonaws.com.
- Works for the zone apex and below:
mydomain.comas well asapp.mydomain.com. - Always of type A (IPv4) or AAAA (IPv6). Route 53 answers with the resource's current IP addresses.
- Automatically follows changes in the resource's IP addresses: load balancer IPs change all the time, and the alias keeps up.
- Free: queries for alias records pointing to AWS resources aren't charged.
- Native health check: with Evaluate target health on, Route 53 stops answering with an unhealthy target.
- The TTL can't be set: Route 53 uses the resource's own TTL.
Alias targets
An alias can point to:
- Elastic Load Balancing load balancers;
- CloudFront distributions;
- API Gateway APIs;
- Elastic Beanstalk environments;
- S3 buckets configured as websites;
- VPC interface endpoints;
- Global Accelerator accelerators;
- App Runner services;
- another Route 53 record in the same hosted zone.
An alias can't point to an EC2 instance's DNS name. Point an A record at its (Elastic) IP address instead.
Real-world examples
- A company wants
example.com(nowww) to reach its ALB. A CNAME isn't allowed at the apex, so it creates an alias A record to the ALB. - A blog points
www.example.comwith a CNAME toexample.github.io, a non-AWS host, where an alias isn't possible.
Exam tips
- "Point the root domain (zone apex) to a load balancer or CloudFront" → alias record.
- "Point a name to a non-AWS hostname" → CNAME (not at the apex).
- "Avoid DNS query charges for AWS resources", "follow the load balancer's changing IPs" → alias.
- "Alias to an EC2 instance" → not possible; use an A record with an Elastic IP.
Common traps
- "Set a TTL of 60 seconds on an alias record." The TTL can't be set on an alias to an AWS resource.
- "Create an A record with the load balancer's current IP." Its IPs change; use an alias.
- "CNAME at the apex is fine in Route 53." It isn't; that's what alias records are for.
Check yourself
An alias lab needs an owned public domain, so instead:
An alias A (and AAAA) record for example.com with the CloudFront distribution as the target. A CNAME isn't allowed at the zone apex.
A CNAME from api.example.com to api.vendor.com. It isn't an AWS resource, so an alias can't point to it, and it isn't the apex, so a CNAME is allowed.
AWS documentation
Records and hosted zones
What a Route 53 record contains, the record types to know, public and private hosted zones, and how TTL trades freshness against cost.
Routing policies
How Route 53 chooses which answer to give, with simple, weighted, latency, failover, geolocation, geoproximity, IP-based and multivalue answer routing.