Amazon Route 53 Tutorial: Create Hosted Zones, Records, Health Checks, and Safe DNS Changes
AWSRoute 53DNSTerraformInfrastructure as CodeFailover

Amazon Route 53 Tutorial: Create Hosted Zones, Records, Health Checks, and Safe DNS Changes

PPlkdt Labs
2026-11-16
8 min read

A practical Route 53 tutorial covering hosted zones, records, health checks, Terraform, IAM, verification, and safe DNS rollbacks.

This Amazon Route 53 tutorial gives you a repeatable workflow for creating hosted zones, delegating a domain, adding records, configuring health checks, automating changes with AWS CLI or Terraform, and verifying a safe rollback before production traffic is affected.

Overview

Amazon Route 53 is a managed DNS service that can host a domain’s authoritative records, route users to applications, perform DNS-based health checks, and apply policies such as weighted or failover routing. The safest way to manage it is to separate planning from execution: first document the intended records, then make the smallest possible change, verify the result from more than one resolver, and keep a tested rollback.

A typical Route 53 workflow has five parts:

  1. Create a public hosted zone for the domain.
  2. Delegate the domain to the hosted zone by updating the registrar’s nameservers.
  3. Add records for websites, APIs, verification tokens, email, and other services.
  4. Use health checks or routing policies only when the application design requires them.
  5. Review, test, and automate future changes with controlled permissions.

Before changing a live zone, make an inventory of the current records and their owners. The DNS record types reference is useful when deciding whether a service needs an A, AAAA, CNAME, TXT, MX, or CAA record. Keep the domain registrar, DNS provider, application owner, and email administrator identified in the same runbook.

Record-planning table

PurposeTypical nameRecord choicePlanning note
Root websiteexample.comA, AAAA, or an AWS aliasCheck whether the target supports an alias at the zone apex.
Application subdomainapp.example.comA, AAAA, or CNAMEConfirm the hosting provider’s target and required TTL.
Email deliveryexample.comMXPreserve all required mail exchangers and priorities.
Service verificationProvider-definedTXT or CNAMECopy the value exactly, including punctuation where required.
Email authentication_dmarc.example.comTXTChange policy deliberately and monitor before enforcement.

Checklist by scenario

Scenario 1: Create a Route 53 hosted zone and connect a domain

  1. In Route 53, create a public hosted zone using the exact domain name, such as example.com. Do not create a second zone accidentally for a similarly named environment.
  2. Record the four nameservers assigned to the hosted zone. They are the authoritative delegation targets.
  3. At the domain registrar, replace the domain’s existing nameservers with the Route 53 nameservers. The registrar is where delegation changes happen; the hosted zone is where records are managed.
  4. Recreate every required record in Route 53 before or immediately after delegation. Include website records, email records, verification records, and any records used by certificates or third-party services.
  5. Confirm delegation with commands such as dig NS example.com and dig +trace example.com. Query the intended record directly with dig A app.example.com or the appropriate record type.

Do not delete the previous DNS zone until the new delegation is confirmed and the record inventory has been compared. DNS answers may differ temporarily because recursive resolvers cache nameserver and record responses.

Scenario 2: Add website or API records

Use an A record for an IPv4 address and an AAAA record for an IPv6 address. Use a CNAME when a hostname should resolve to another hostname, subject to the usual restriction that a CNAME is not used at the zone apex. Route 53 alias records are an AWS-specific option for supported AWS targets and can be used where a CNAME would not be appropriate, including some root-domain configurations.

For a simple record change, the AWS CLI can apply a JSON change batch:

cat > change.json <<'JSON'
{
  "Comment": "Point app to the approved endpoint",
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "app.example.com.",
        "Type": "CNAME",
        "TTL": 300,
        "ResourceRecords": [{"Value": "target.example.net."}]
      }
    }
  ]
}
JSON

aws route53 change-resource-record-sets \
  --hosted-zone-id ZONE_ID \
  --change-batch file://change.json

Use UPSERT only when replacing or creating the complete intended record set. For weighted, latency, or failover records, include the required routing-policy fields and a unique SetIdentifier; do not treat those records like an ordinary single-value record.

Scenario 3: Add health checks and failover routing

A Route 53 health check can monitor an endpoint or another configured health-check target. The check should represent real service availability rather than merely whether a TCP port is open. A dedicated endpoint such as /healthz should return a predictable success response without depending on an unrelated downstream system unless that dependency is part of the failure you intend to detect.

For active-passive routing, create a primary and secondary record with the same name and type, assign primary and secondary failover roles, and associate the primary with a health check where appropriate. Verify that the secondary target is actually ready to receive traffic before testing. A health check alone does not create failover behavior; the records must use a compatible routing policy.

Weighted routing is useful for controlled distribution or a gradual migration. Assign weights deliberately, give each record a unique identifier, and decide what should happen when a record is unhealthy. Test with low-risk traffic or a separate hostname before applying the pattern to the primary domain.

Scenario 4: Manage records with Terraform

Terraform makes DNS changes reviewable, repeatable, and easier to recover from, but only when the existing zone is represented accurately in state. Import resources that already exist instead of allowing a new configuration to overwrite them unexpectedly. A minimal configuration may look like this:

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

resource "aws_route53_record" "app" {
  zone_id = aws_route53_zone.primary.zone_id
  name    = "app.example.com"
  type    = "CNAME"
  ttl     = 300
  records = ["target.example.net"]
}

Run terraform fmt, terraform validate, and terraform plan before applying. Review the plan for accidental deletion of MX, TXT, certificate-validation, or delegation-related records. Keep production applies behind code review and use separate state or clearly separated modules for different environments.

What to double-check before and after a change

  • Zone identity: Verify the hosted zone ID and domain name. Duplicate hosted zones are a common source of confusion.
  • Nameserver delegation: Confirm the registrar points to the intended Route 53 nameservers, not an older zone.
  • Record name formatting: AWS tools and DNS interfaces may display fully qualified names with a trailing dot. Check that an intended root record was not created as a duplicated subdomain.
  • Existing record sets: Compare the complete set, especially MX, TXT, CAA, DKIM, and service-verification records.
  • Routing policy: Confirm that all records sharing a name and type have compatible policy fields, identifiers, and health-check associations.
  • TTL expectations: A lower TTL can help planned changes become visible sooner, but cached answers cannot be recalled. Lower the TTL before a migration when practical, then restore an appropriate value afterward.
  • Application readiness: Confirm the target accepts the hostname, has a valid certificate, and is ready for traffic before changing DNS.
  • Independent verification: Query authoritative nameservers directly and also test through more than one recursive resolver. DNS propagation is a caching process, not a single global switch.
  • Rollback: Save the previous record value, routing policy, TTL, and health-check association before applying the change.

For repeatable command-line checks, pair dig with a small shell script or use curl to test the application after resolution changes. The curl and jq API testing guide can help when the DNS target is an API rather than a static website.

Common mistakes

Changing records in the wrong hosted zone

A domain can have multiple Route 53 hosted zones with the same name. The public internet follows the zone named by the registrar delegation, so editing an undelegated zone has no production effect. Always confirm the hosted zone ID and authoritative nameservers.

Replacing the zone instead of adding one record

Bulk imports and infrastructure changes can remove records that were not included in the new configuration. Treat DNS as shared production infrastructure. Export or document the current record set, review the diff, and use narrowly scoped changes where possible.

Breaking email while changing web DNS

Website records and mail records are separate, but they often live in the same zone. Preserve MX, SPF, DKIM, and DMARC records during migrations. Use the SPF, DKIM, and DMARC setup guide when email authentication is part of the change.

Testing failover without testing the fallback

A secondary record that exists in DNS may still point to an unready application. Test the fallback independently, confirm its certificate and dependencies, and define how to return to the primary path after the exercise.

Assuming DNS is the only cause of an outage

If dig returns the expected address but the site fails, investigate TLS, load balancers, security groups, application routing, and origin health. DNS can direct traffic correctly while the service behind it remains unavailable.

When to revisit

Revisit this Route 53 checklist before a domain migration, hosting change, failover exercise, certificate rollout, email-provider change, or seasonal planning cycle. It should also be reviewed when your team changes how DNS is managed—for example, moving from console edits to Terraform, introducing preview environments, or adding automated deployment workflows.

At minimum, schedule a DNS inventory review twice a year and after any incident involving name resolution. Confirm that the registrar delegation, hosted zones, records, IAM permissions, health checks, Terraform state, and rollback instructions still match reality. AWS Console labels, CLI behavior, provider resources, and pricing can change, so verify current implementation details against the relevant AWS documentation before production work.

Use this final pre-change checklist:

  1. Write down the intended hostname, record type, value, TTL, and routing policy.
  2. Confirm the correct hosted zone and current authoritative nameservers.
  3. Export or record the current value and define the rollback command or Terraform change.
  4. Check application readiness, certificates, email records, and dependent services.
  5. Apply the smallest reviewed change with an appropriately scoped IAM identity.
  6. Verify authoritative answers, recursive answers, HTTP or API behavior, and monitoring.
  7. Record the result in the DNS runbook and note when the next review is due.

For a broader operational workflow covering audits, automation, and troubleshooting across providers, see the DNS runbook guide. A consistent record inventory and rollback habit will usually prevent more DNS incidents than a complex routing design.

Related Topics

#AWS#Route 53#DNS#Terraform#Infrastructure as Code#Failover
P

Plkdt Labs

Developer Tools and Infrastructure Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.