A Record vs CNAME vs Alias in Route 53: Key Differences and Usage
A record maps a domain directly to an IP address, a CNAME record maps a domain to another domain name, and an alias record is a Route 53-specific feature that maps a domain to AWS resources like CloudFront or ELB without extra DNS queries. Alias records are preferred for AWS resources because they are free and support root domains, unlike CNAMEs.Quick Comparison
Here is a quick comparison of A record, CNAME record, and alias record in Route 53 based on key factors.
| Feature | A Record | CNAME Record | Alias Record |
|---|---|---|---|
| Points to | IP address | Another domain name | AWS resource or domain name |
| Supports root domain (example.com) | Yes | No | Yes |
| DNS query cost | Standard | Standard | Free within Route 53 |
| Use with AWS services | No | No | Yes (CloudFront, ELB, S3, etc.) |
| Allows chaining | No | Yes | No |
| TTL control | Yes | Yes | No (managed by AWS) |
Key Differences
A record directly links your domain to an IP address. This means when someone types your domain, DNS returns the IP to connect to. It works for root domains like example.com but requires you to manage IP addresses manually.
CNAME record points your domain to another domain name instead of an IP. This is useful for subdomains like www.example.com pointing to example.net. However, CNAMEs cannot be used at the root domain level because DNS rules forbid it.
Alias record is a special Route 53 feature that acts like a CNAME but can be used at the root domain and points directly to AWS resources such as CloudFront distributions, Elastic Load Balancers, or S3 buckets. Alias records do not incur extra DNS query charges and AWS manages their IP addresses automatically, making them easier and cheaper to use with AWS services.
Code Comparison
Here is how you create an A record in Route 53 using AWS CLI to point example.com to an IP address.
{
"Comment": "Create A record for example.com",
"Changes": [
{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "example.com.",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{"Value": "192.0.2.44"}
]
}
}
]
}Alias Record Equivalent
Here is how you create an alias record in Route 53 using AWS CLI to point example.com to an AWS Elastic Load Balancer.
{
"Comment": "Create alias record for example.com to ELB",
"Changes": [
{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "example.com.",
"Type": "A",
"AliasTarget": {
"HostedZoneId": "Z35SXDOTRQ7X7K",
"DNSName": "my-load-balancer-1234567890.us-west-2.elb.amazonaws.com.",
"EvaluateTargetHealth": false
}
}
}
]
}When to Use Which
Choose A record when you have a fixed IP address to point your domain to, especially for root domains without AWS resources.
Choose CNAME record for subdomains that need to point to other domain names outside AWS or when you want to alias one domain to another but not at the root level.
Choose alias record when pointing your domain (including root) to AWS resources like CloudFront, ELB, or S3 buckets because it is cost-effective, supports root domains, and AWS manages the IP addresses automatically.