Route 53: DNS, alias records and routing

Amazon Web Services · Practical · 12 min

DNS is how users find your service, and Route 53's routing policies are a key tool for releases and disaster recovery.

Route 53 is AWS's DNS service. A hosted zone holds records for a domain; public zones answer the internet, private zones answer only inside associated VPCs. To use a zone for a domain registered elsewhere, set the registrar's NS records to the four name servers Route 53 assigns.

Record types are the usual ones (A, AAAA, CNAME, MX, TXT, CAA) plus a Route 53 extension, the alias record. An alias points a name at an AWS resource such as an ALB, CloudFront distribution, S3 website or another record. Unlike a CNAME it works at the zone apex (example.com), follows the target's changing IPs automatically, and queries to AWS targets are free.

TTL controls how long resolvers cache answers. Lower it a day before a planned migration; keep it moderate otherwise.

Routing policies let one name return different answers:

  • Weighted: split traffic, for example 90/10 for a canary.
  • Latency: answer with the Region closest in latency to the user.
  • Failover: primary and secondary, switching when a health check fails.
  • Geolocation / geoproximity: by user location, for compliance or localisation.
  • Multivalue: up to eight healthy records, simple client-side balancing.

Health checks probe endpoints (or watch CloudWatch alarms) and remove unhealthy answers. Remember DNS failover is only as fast as TTLs and client caching allow; it is a Region-level tool, not a substitute for load balancers within a Region.

Example

cat > change.json <<'EOF'
{"Comment": "Point the API at the ALB",
 "Changes": [{"Action": "UPSERT",
   "ResourceRecordSet": {
     "Name": "api.example.com", "Type": "A",
     "AliasTarget": {
       "HostedZoneId": "Z32O12XQLNTSW2",
       "DNSName": "dualstack.web-alb-1234567890.eu-west-1.elb.amazonaws.com",
       "EvaluateTargetHealth": true}}}]}
EOF
aws route53 change-resource-record-sets --hosted-zone-id Z0123456789ABCDEFGHIJ \
  --change-batch file://change.json --query ChangeInfo.Status --output text
# PENDING   (INSYNC within about a minute)

dig +short api.example.com
# 52.48.12.34
# 34.250.7.89

Remember

  • Hosted zones hold records; delegate with NS records at the registrar
  • Alias records work at the apex and track AWS resources' IPs
  • Weighted, latency and failover policies steer traffic
  • DNS changes are bounded by TTL and client caching

Watch out for

  • Using a CNAME at the zone apex, which DNS forbids; use an alias record.

Check yourself

  1. You want example.com (no www) to point at a CloudFront distribution. Which record?
  2. Which routing policy sends 5% of traffic to a new stack?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html