Customers type monstermarket.example, not www. That name, the zone's own, is the apex, and it already holds the NS and SOA records. A CNAME means "this name is really that one", so it cannot share a name with anything: no CNAME at the apex.
Alias records
An alias is Route 53's own kind of record, usually an A record (an AAAA alias does the same for IPv6). Instead of a value, it names a target, and Route 53 looks the target up and answers with its addresses.
| CNAME | Alias | |
|---|---|---|
| At the apex | no | yes |
| Points at | any name | load balancers, CloudFront, S3 websites, a record in the zone; never an instance |
| The answer | a name to look up | addresses |
| Queries | charged | free for AWS targets |
The apex to the load balancer
An alias names the target's DNS name and the id of AWS's hosted zone for that target, not your zone's id: every load balancer reports it as CanonicalHostedZoneId.
aws elbv2 describe-load-balancers --names market-alb --query "LoadBalancers[0].[DNSName,CanonicalHostedZoneId]" --output text{ "Changes": [ { "Action": "UPSERT", "ResourceRecordSet": {
"Name": "monstermarket.example", "Type": "A",
"AliasTarget": { "HostedZoneId": "Z35SXDOTRQ7X7K",
"DNSName": "LB-DNS",
"EvaluateTargetHealth": true } } } ] }With the two values from the command above in place of Z35SXDOTRQ7X7K (it is the same for every load balancer in us-east-1) and LB-DNS, saved as apex.json:
aws route53 change-resource-record-sets --hosted-zone-id $ZONE --change-batch file://apex.jsonThere is no TTL: the answer carries the target's. With EvaluateTargetHealth, Route 53 treats the record as unhealthy while the load balancer has no healthy target (it matters with routing, next).
dig +short monstermarket.exampleTwo addresses, one per Availability Zone of the load balancer, and they change as it scales; the alias follows.
curl -s http://monstermarket.example/Other targets
- CloudFront: zone
Z2FDTNDATAQYW2, and the distribution must list the name (later this chapter). - An S3 website:
DNSNames3-website-us-east-1.amazonaws.com, zoneZ3AQBSTGFYJSTF. S3 picks the bucket by the name the browser asked for, so the bucket must be named exactly like the record:promo.monstermarket.example. Otherwise S3 answersNoSuchBucket. - Another record in the same zone: the zone's own id.
Give your own zone's id instead of the target's and Route 53 refuses: the alias target name does not lie within the target zone.