Module 10 of 13 · AWS Fundamentals · Beginner

Route 53 & DNS

Duration: 45 min

Amazon Route 53 is AWS's DNS service. It translates domain names to IP addresses and routes traffic to your resources. This module covers hosted zones, record types, routing policies, and health checks.

DNS Basics

DNS (Domain Name System) translates human-readable domain names (example.com) to IP addresses (192.0.2.1). When you type a URL in your browser, DNS resolves it to an IP address.

Route 53 is AWS's managed DNS service. It's highly available, scalable, and integrates with other AWS services.

Hosted Zones

A hosted zone is a container for DNS records for a specific domain. When you register a domain with Route 53 or transfer it from another registrar, you create a hosted zone.

Route 53 provides name servers for your hosted zone. You update your domain registrar to point to these name servers.

Record Types

A records map domain names to IPv4 addresses.

AAAA records map domain names to IPv6 addresses.

CNAME records create aliases to other domain names (e.g., www.example.com → example.com).

MX records specify mail servers for email delivery.

TXT records store text data (e.g., SPF, DKIM for email authentication).

NS records specify name servers for a domain.

SOA records contain zone authority information.

Routing Policies

Simple routing directs traffic to a single resource.

Weighted routing distributes traffic based on weights (e.g., 70% to one resource, 30% to another).

Latency-based routing directs traffic to the resource with lowest latency.

Failover routing directs traffic to a primary resource; if it fails, traffic goes to a secondary resource.

Geolocation routing directs traffic based on geographic location.

Multi-value answer routing returns multiple IP addresses randomly.

Health Checks

Health checks monitor the health of your resources. If a resource fails a health check, Route 53 stops routing traffic to it.

Health checks can monitor HTTP endpoints, TCP connections, or CloudWatch alarms.

Hands-On: Create Hosted Zone and Records

Create a hosted zone:

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

List hosted zones:

aws route53 list-hosted-zones

Create an A record:

aws route53 change-resource-record-sets --hosted-zone-id ZONE_ID \
  --change-batch '{
    "Changes": [
      {
        "Action": "CREATE",
        "ResourceRecordSet": {
          "Name": "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 ZONE_ID \
  --change-batch '{
    "Changes": [
      {
        "Action": "CREATE",
        "ResourceRecordSet": {
          "Name": "www.example.com",
          "Type": "CNAME",
          "TTL": 300,
          "ResourceRecords": [{"Value": "example.com"}]
        }
      }
    ]
  }'

Create a health check:

aws route53 create-health-check --health-check-config '{
  "Type": "HTTP",
  "ResourcePath": "/health",
  "FullyQualifiedDomainName": "example.com",
  "Port": 80,
  "RequestInterval": 30,
  "FailureThreshold": 3
}'

Python Boto3 Example

import boto3

route53 = boto3.client('route53')

# Create hosted zone
response = route53.create_hosted_zone(
    Name='example.com',
    CallerReference='unique-ref-123'
)
zone_id = response['HostedZone']['Id']

# Create A record
route53.change_resource_record_sets(
    HostedZoneId=zone_id,
    ChangeBatch={
        'Changes': [
            {
                'Action': 'CREATE',
                'ResourceRecordSet': {
                    'Name': 'example.com',
                    'Type': 'A',
                    'TTL': 300,
                    'ResourceRecords': [{'Value': '192.0.2.1'}]
                }
            }
        ]
    }
)

# List records
response = route53.list_resource_record_sets(HostedZoneId=zone_id)
for record in response['ResourceRecordSets']:
    print(f"{record['Name']} ({record['Type']})")

Terraform Example

resource "aws_route53_zone" "main" {
  name = "example.com"
}

resource "aws_route53_record" "www" {
  zone_id = aws_route53_zone.main.zone_id
  name    = "www.example.com"
  type    = "A"
  ttl     = 300
  records = ["192.0.2.1"]
}

resource "aws_route53_record" "alias" {
  zone_id = aws_route53_zone.main.zone_id
  name    = "example.com"
  type    = "A"

  alias {
    name                   = aws_cloudfront_distribution.s3.domain_name
    zone_id                = aws_cloudfront_distribution.s3.hosted_zone_id
    evaluate_target_health = false
  }
}

resource "aws_route53_health_check" "main" {
  fqdn              = "example.com"
  port              = 80
  type              = "HTTP"
  resource_path     = "/health"
  failure_threshold = 3
  request_interval  = 30
}

Alias Records

Alias records are Route 53-specific records that map to AWS resources (CloudFront, ELB, S3 websites). Unlike CNAME records, alias records can be created at the zone apex (example.com).

Quiz 1

❓ What is Route 53?

Quiz 2

❓ What is a hosted zone?

Quiz 3

❓ What does an A record do?

Quiz 4

❓ What is latency-based routing?

Quiz 5

❓ What is a health check in Route 53?

← Previous Continue interactively → Next →

Related Courses