Interview Prep/AWS/Route 53, CloudFront, API Gateway and Messaging

`InvalidChangeBatch: RRSet of type CNAME with DNS name example.com. is not permitted at apex in zone example.com.`

BeginnerTroubleshootingRoute 53, CloudFront, API Gateway and Messaging
Answer

Likely causes → DNS does not allow a CNAME at the zone apex, because it would clash with the SOA and NS records there.

Diagnose →

aws route53 list-resource-record-sets --hosted-zone-id Z0123ABC --query "ResourceRecordSets[?Name=='example.com.']"

Fix → Use a Route 53 alias A/AAAA record to the ALB, CloudFront or S3 target:

aws route53 change-resource-record-sets --hosted-zone-id Z0123ABC --change-batch '{
 "Changes":[{"Action":"UPSERT","ResourceRecordSet":{"Name":"example.com","Type":"A",
 "AliasTarget":{"HostedZoneId":"Z35SXDOTRQ7X7K","DNSName":"dualstack.web-123.us-east-1.elb.amazonaws.com","EvaluateTargetHealth":true}}}]}'

The alias HostedZoneId is the load balancer's canonical zone ID, not your zone's ID.

Prevent → Use alias records for AWS targets everywhere. They are free to query and follow IP changes automatically.

aws All AWS questions Roadmap: AWS core services

More on Route 53, CloudFront, API Gateway and Messaging