Skip to content
intermediate Phase 2 · AWS Networking

Route 53 DNS

Manage DNS records, health checks, and routing policies with Route 53.

1h
0 problems
Topic Progress 0%

Route 53 Fundamentals

Route 53 Fundamentals

Amazon Route 53 is a highly available and scalable cloud Domain Name System (DNS) web service.

Core Features

  • Domain Registration: Register domain names
  • DNS Routing: Route users to applications
  • Health Checking: Monitor endpoint health
  • Domain Transfer: Transfer domains to/from Route 53

Hosted Zones

# Create a hosted zone
aws route53 create-hosted-zone \
  --name example.com \
  --caller-reference $(date +%s)

# List hosted zones
aws route53 list-hosted-zones

# Get name servers for delegation
aws route53 get-hosted-zone --id /hosted-zone/Z1234567890

# Example output: name servers
# ns-1234.awsdns-26.org
# ns-567.awsdns-09.com
# ns-890.awsdns-45.net
# ns-123.awsdns-10.co.uk

Record Types

Type Use Case Example
A IPv4 address 192.0.2.1
AAAA IPv6 address 2001:db8::1
CNAME Alias to another domain www.example.com → example.com
MX Mail exchange 10 mail.example.com
TXT Text information (SPF, DKIM) "v=spf1 include:..."
SOA Start of Authority Zone information
NS Name servers Delegation

DNS Record Management

DNS Record Management

Create DNS Records

# Create an A record
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [{
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "www.example.com",
        "Type": "A",
        "TTL": 300,
        "ResourceRecords": [{"Value": "192.0.2.1"}]
      }
    }]
  }'

# Create a CNAME record
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [{
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "api.example.com",
        "Type": "CNAME",
        "TTL": 300,
        "ResourceRecords": [{"Value": "my-alb-123456.us-east-1.elb.amazonaws.com"}]
      }
    }]
  }'

# Create an MX record
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [{
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com",
        "Type": "MX",
        "TTL": 3600,
        "ResourceRecords": [{"Value": "10 mail.example.com"}]
      }
    }]
  }'

# List records
aws route53 list-resource-record-sets --hosted-zone-id Z1234567890

# Delete a record
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [{
      "Action": "DELETE",
      "ResourceRecordSet": {
        "Name": "old.example.com",
        "Type": "A",
        "TTL": 300,
        "ResourceRecords": [{"Value": "192.0.2.1"}]
      }
    }]
  }'

TTL Considerations

  • Low TTL (30-60s): Fast propagation, higher query costs
  • Medium TTL (300s): Balanced approach
  • High TTL (3600s): Lower costs, slower propagation

Routing Policies

Routing Policies

Simple Routing

Single record with no special routing logic.

Weighted Routing

Distribute traffic across multiple resources by percentage.

# Weighted: 70% to us-east-1, 30% to eu-west-1
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [
      {
        "Action": "CREATE",
        "ResourceRecordSet": {
          "Name": "www.example.com",
          "Type": "A",
          "SetIdentifier": "us-east-1",
          "Weight": 70,
          "TTL": 300,
          "ResourceRecords": [{"Value": "192.0.2.1"}]
        }
      },
      {
        "Action": "CREATE",
        "ResourceRecordSet": {
          "Name": "www.example.com",
          "Type": "A",
          "SetIdentifier": "eu-west-1",
          "Weight": 30,
          "TTL": 300,
          "ResourceRecords": [{"Value": "198.51.100.1"}]
        }
      }
    ]
  }'

Latency-Based Routing

Route to the region with lowest latency.

aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [
      {
        "Action": "CREATE",
        "ResourceRecordSet": {
          "Name": "www.example.com",
          "Type": "A",
          "SetIdentifier": "us-east-1",
          "Region": "us-east-1",
          "TTL": 300,
          "ResourceRecords": [{"Value": "192.0.2.1"}]
        }
      },
      {
        "Action": "CREATE",
        "ResourceRecordSet": {
          "Name": "www.example.com",
          "Type": "A",
          "SetIdentifier": "eu-west-1",
          "Region": "eu-west-1",
          "TTL": 300,
          "ResourceRecords": [{"Value": "198.51.100.1"}]
        }
      }
    ]
  }'

Failover Routing

Primary/secondary configuration for disaster recovery.

# Primary record
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [{
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "www.example.com",
        "Type": "A",
        "SetIdentifier": "primary",
        "Failover": "PRIMARY",
        "TTL": 60,
        "ResourceRecords": [{"Value": "192.0.2.1"}],
        "HealthCheckId": "xxx"
      }
    }]
  }'

# Secondary record
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234567890 \
  --change-batch '{
    "Changes": [{
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "www.example.com",
        "Type": "A",
        "SetIdentifier": "secondary",
        "Failover": "SECONDARY",
        "TTL": 60,
        "ResourceRecords": [{"Value": "198.51.100.1"}]
      }
    }]
  }'

Health Checks

Health Checks

Route 53 health checks monitor endpoint availability.

Create Health Checks

# HTTP health check
aws route53 create-health-check \
  --caller-reference $(date +%s) \
  --health-check-config '{
    "IPAddress": "192.0.2.1",
    "Port": 80,
    "Type": "HTTP",
    "ResourcePath": "/health",
    "RequestInterval": 30,
    "FailureThreshold": 3,
    "EnableSNI": true
  }'

# HTTPS health check
aws route53 create-health-check \
  --caller-reference $(date +%s) \
  --health-check-config '{
    "IPAddress": "192.0.2.1",
    "Port": 443,
    "Type": "HTTPS",
    "ResourcePath": "/health",
    "RequestInterval": 10,
    "FailureThreshold": 2
  }'

# TCP health check (no HTTP)
aws route53 create-health-check \
  --caller-reference $(date +%s) \
  --health-check-config '{
    "IPAddress": "192.0.2.1",
    "Port": 3306,
    "Type": "TCP",
    "RequestInterval": 10,
    "FailureThreshold": 3
  }'

Health Check Monitoring

# Get health check status
aws route53 get-health-check-status --health-check-id xxx

# Get health check events
aws route53 list-health-checks --query 'HealthChecks[*].[Id,HealthCheckConfig.Type,HealthCheckConfig.IPAddress]'

# CloudWatch metrics for health checks
aws cloudwatch get-metric-statistics \
  --namespace AWS/Route53 \
  --metric-name HealthCheckStatus \
  --dimensions Name=HealthCheckId,Value=xxx \
  --start-time $(date -u -d '1 hour ago') \
  --end-time $(date -u) \
  --period 60 \
  --statistics Minimum

Domain Registration and Migration

Domain Registration and Migration

Register a Domain

# Check domain availability
aws route53 domains check-domain-availability --domain-name example.com

# Estimate cost
aws route53 domains get-domain-price-list

# Register domain
aws route53 domains register-domain \
  --domain-name example.com \
  --admin-contact '{
    "FirstName": "John",
    "LastName": "Doe",
    "Email": "john@example.com",
    "Phone": "+1.5551234567",
    "Country": "US",
    "City": "New York",
    "AddressLine1": "123 Main St",
    "State": "NY",
    "PostalCode": "10001"
  }' \
  --registrant-contact '{...same structure...}' \
  --tech-contact '{...same structure...}' \
  --duration-in-years 1 \
  --auto-renew true

# List registered domains
aws route53 domains list-domains

# Get domain details
aws route53 domains get-domain-detail --domain-name example.com

Transfer Domain to Route 53

# Get authorization code from current registrar
# Then transfer:
aws route53 domains transfer-domain-to-route53 \
  --domain-name example.com \
  --auth-code "TRANSFER_CODE_HERE" \
  --duration-in-years 1

# Check transfer status
aws route53 domains get-domain-detail --domain-name example.com
# Status will show: PENDING_TRANSFER, IN_PROGRESS, TRANSFER_FAILED

Architecture: Multi-Region with Route 53

                    ┌──────────────┐
                    │   Route 53   │
                    │ Latency-based│
                    │   routing    │
                    └──────┬───────┘
                           │
            ┌──────────────┼──────────────┐
            │              │              │
    ┌───────▼──────┐┌─────▼──────┐┌──────▼───────┐
    │  us-east-1   ││ eu-west-1  ││ ap-southeast-1│
    │    ALB       ││    ALB     ││     ALB      │
    │  ┌──────┐    ││  ┌──────┐  ││   ┌──────┐   │
    │  │ EC2  │    ││  │ EC2  │  ││   │ EC2  │   │
    │  └──────┘    ││  └──────┘  ││   └──────┘   │
    └──────────────┘└────────────┘└──────────────┘