DevOps.Academy
CoursesCurriculumInterview prepPricing
◔My learningSign in
DevOps.Academy

Free, hands-on DevOps lessons. Made with care in India.

System status

Learn

All coursesLinux roadmapCurriculumInterview questionsCheat sheetsMy learning

Academy

PricingCertificates

Legal

PrivacyTermsContact

devops.rajeev.pro

AWS for DevOpsLesson 8 of 17
Your progress · 0%
On this page
  1. DNS in one minute
  2. Hosted zones
  3. Records
  4. Routing policies
  5. Health checks
  6. Domain registration
↖ Course roadmap
Lesson 8 · Route 53

Route 53: DNS for your apps

Create a private hosted zone in the console, add A, CNAME and alias records, pick a routing policy, add health checks, and clean up without buying a domain.

30 min read · intermediate · hands-on

By the end of this lesson you'll be able to

0 of 5 complete

DNS in one minute

Before DNS, a client would need a server's IP address written directly into configuration. When the server moved, every client with the old address had to be updated. DNS lets a client ask for a stable name and receive the address selected by a resolver.

Domain Name System (DNS) maps names such as api.example.com to records that clients can use. Amazon Route 53 hosts DNS zones and answers queries; it can also check endpoint health and register domains. A resolver asks the authoritative servers for the record, caches the answer for its time to live (TTL), and returns it to the client. The name Route 53 refers to DNS's port number, 53.

Everything below was done in a real practice account with a private zone, which costs nothing if deleted within 12 hours, and then deleted. No domain was bought and no public DNS changed.

In this lesson you'll create a private hosted zone linked to a VPC, add records and inspect routing policies. Private DNS answers are visible only to associated VPCs, so this exercise does not change a public website.

The resolver walks root, .com and Route 53 once, then answers from its cache until the TTL runs out.© Diagram: DevOps Academy

The resolver walks root, .com and Route 53 once, then answers from its cache until the TTL runs out.© Diagram: DevOps Academy

Hosted zones

A hosted zone is the authoritative container for records under a domain name. Without a zone, the DNS system has no place where your team can define the answers for academy.internal or example.com. Route 53 offers public zones, queried through public DNS, and private zones, associated with one or more VPCs.

When a resolver asks about a name, Route 53 finds the matching zone and returns the record data and TTL. A private zone answers only for queries coming from associated VPCs with DNS support enabled. A public zone is reachable through the public DNS hierarchy, but creating it alone does not make it authoritative for a registered domain; the registrar's name-server delegation must point to it.

The two kinds of zone serve different audiences:

ZoneAnswersUse for
Publicanyone on the internetyour website and APIs (example.com)
Privateonly from VPCs you associate with itinternal service names (db.academy.internal)

Route 53 → Hosted zones → Create hosted zone:

(1) The domain. (2) Private: answers only inside the VPCs you pick. (3) The VPC that can resolve it.© Screenshot: DevOps Academy

(1) The domain. (2) Private: answers only inside the VPCs you pick. (3) The VPC that can resolve it.© Screenshot: DevOps Academy

A private zone needs the VPC's DNS hostnames and DNS resolution settings turned on; the default VPC and lesson 4's wizard VPC have both. A new zone starts with two records Route 53 manages for you: NS (the name servers answering for the zone) and SOA (zone metadata).

Use a private zone for internal service names and a public zone for names customers must resolve on the internet. A common mistake is creating a public zone and assuming the domain now points to it. Change the registrar's name-server delegation only when you intend to move live DNS; this lesson uses a private zone and does not touch a public domain.

Records

(1) An A record. (2) A CNAME pointing one name at another. (3) Create record adds more.© Screenshot: DevOps Academy

(1) An A record. (2) A CNAME pointing one name at another. (3) Create record adds more.© Screenshot: DevOps Academy
TypePoints toExample
A / AAAAan IPv4 / IPv6 addressapi.academy.internal → 10.0.0.10
CNAMEanother name (never at the zone apex)www → web.academy.internal
Aliasan AWS resource: ALB, CloudFront, S3 website, another recordexample.com → my-alb-123.elb.amazonaws.com
MX / TXTmail servers / text, such as domain verificationTXT "v=spf1 …"

Alias is Route 53's own record: it works at the zone apex (example.com itself, where CNAMEs aren't allowed), follows the target's IP addresses as they change, and queries to AWS targets are free. Point domains at lesson 5's load balancer or lesson 9's CloudFront with an alias.

TTL (time to live) is how long resolvers cache an answer. 300 seconds is a sensible default; lower it a day before a planned change so the switch spreads quickly.

(1) The name. (2) The type. (3) The routing policy: Simple returns the same answer to everyone.© Screenshot: DevOps Academy

(1) The name. (2) The type. (3) The routing policy: Simple returns the same answer to everyone.© Screenshot: DevOps Academy

Routing policies

The record wizard shows every policy:

Simple, plus six ways to choose between several answers. (1) Weighted, (2) Failover and (3) Latency are the ones you'll use most.© Screenshot: DevOps Academy

Simple, plus six ways to choose between several answers. (1) Weighted, (2) Failover and (3) Latency are the ones you'll use most.© Screenshot: DevOps Academy
PolicyAnswers withUse for
Simplethe same value for everyoneone endpoint
Weightedeach record in proportion to its weightcanary releases: 90% old, 10% new
Latencythe Region with the lowest latency to the userapps running in several Regions
Failoverprimary while healthy, otherwise secondarydisaster recovery
Geolocationby the user's country or continentlegal or language requirements
Multivalueup to eight healthy records at randomsimple client-side spreading
Master AWS Route 53: Hands-On Geolocation, Weighted & Failover RoutingMechCloud Academy · Watch on YouTube ↗

Health checks

An endpoint health check calls a URL from locations around the world and marks it unhealthy when it fails.© Screenshot: DevOps Academy

An endpoint health check calls a URL from locations around the world and marks it unhealthy when it fails.© Screenshot: DevOps Academy

Attach a health check to a failover or weighted record, and Route 53 stops returning an unhealthy answer. Check a path that proves the app works (/health that touches the database), not just that a port is open. Health checks cost a little per month each, so this lesson only opened the form.

Amazon Route 53: Health Checks and DNS FailoverStormit · Watch on YouTube ↗

Domain registration

When a team needs a new public name, it must register the domain with a registrar and then publish the DNS records that direct traffic to its services. Route 53 can act as both registrar and DNS host, but those are separate jobs: registration reserves the name; a hosted zone contains its records.

Registered domains → Register domains purchases a domain through Route 53 and creates its public hosted zone. If a domain is registered elsewhere, create the zone and update the registrar's name-server delegation to the four servers in its NS record. DNS changes can take time to propagate because resolvers cache answers. Registration costs money and renews yearly, so it is not part of a practice mission.

Register through Route 53 only when its pricing, supported suffix and renewal terms fit the requirement. If you already own the domain elsewhere, keep the registrar and delegate DNS to Route 53 instead. A common mistake is treating a zone as proof that you own a domain; only registration gives you that ownership, and a public zone that is not delegated will not answer authoritative lookups for visitors.

Delete records before the zone

Route 53 refuses to delete a hosted zone that still has records other than NS and SOA. Delete your records first, then the zone. A hosted zone kept longer than 12 hours is billed for the month.

In production

Keep public zones in code (Terraform or CloudFormation), use alias records for AWS endpoints, keep TTLs short around migrations, use private zones for internal names instead of hard-coded IPs, and protect the domain with registrar lock and auto-renew so it can never lapse.

⌘
Mini mission

Private DNS for a VPC

Create a private hosted zone attached to your default VPC, add two A records and a CNAME, list them, then delete the records and the zone and confirm it's gone.

Input: An AWS account and the AWS CLI configured for ap-south-1Output: Five records (NS, SOA, two A, one CNAME), then no academy.internal zone
Reveal one safe solution
$ VPC=$(aws ec2 describe-vpcs --filters Name=isDefault,Values=true --query 'Vpcs[0].VpcId' --output text)
$ Z=$(aws route53 create-hosted-zone --name academy.internal --caller-reference academy-$RANDOM \
    --vpc VPCRegion=ap-south-1,VPCId=$VPC --query HostedZone.Id --output text)
$ cat > rec.json <<'EOF'
{"Changes":[
 {"Action":"CREATE","ResourceRecordSet":{"Name":"api.academy.internal","Type":"A","TTL":300,"ResourceRecords":[{"Value":"10.0.0.10"}]}},
 {"Action":"CREATE","ResourceRecordSet":{"Name":"web.academy.internal","Type":"A","TTL":300,"ResourceRecords":[{"Value":"10.0.0.20"}]}},
 {"Action":"CREATE","ResourceRecordSet":{"Name":"www.academy.internal","Type":"CNAME","TTL":300,"ResourceRecords":[{"Value":"web.academy.internal"}]}}]}
EOF
$ aws route53 change-resource-record-sets --hosted-zone-id $Z --change-batch file://rec.json
$ aws route53 list-resource-record-sets --hosted-zone-id $Z --query 'ResourceRecordSets[].[Name,Type,ResourceRecords[0].Value]' --output text
academy.internal.	NS	ns-1536.awsdns-00.co.uk.
academy.internal.	SOA	ns-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
api.academy.internal.	A	10.0.0.10
web.academy.internal.	A	10.0.0.20
www.academy.internal.	CNAME	web.academy.internal
$ sed 's/"CREATE"/"DELETE"/g' rec.json > del.json
$ aws route53 change-resource-record-sets --hosted-zone-id $Z --change-batch file://del.json
$ aws route53 delete-hosted-zone --id $Z
$ aws route53 list-hosted-zones-by-name --dns-name academy.internal --query 'HostedZones[?Name==`academy.internal.`]'
[]
cat > rec.json <<'EOF'
  • catprint a file
  • >write output to a file, replacing it
aws route53 change-resource-record-sets --hosted-zone-id $Z --change-batch file://rec.json
  • awsthe AWS command line
aws route53 list-resource-record-sets --hosted-zone-id $Z --query 'ResourceRecordSets[].[Name,Type,ResourceRecords[0].Value]' --output text
  • --querypick fields from the JSON response
  • --outputoutput format

Your name servers will differ. A delete batch must match each record exactly, which is why reusing the create file with DELETE is the safe way to remove them.

Try it yourself

0 of 4 steps done

Run each task in your own account or terminal, then tick it off.

Knowledge check

Quick check

Question 1 of 5

Which hosted zone resolves names only inside associated VPCs?

Go deeper

Official reading for this lesson

  • DocsAmazon Route 53 Developer GuideAWS Docs ↗
  • GuideWorking with hosted zonesAWS Docs ↗
  • DocsChoosing a routing policyAWS Docs ↗
  • DocsRoute 53 health checksAWS Docs ↗
  • GuideRoute 53 pricingAWS ↗

Or get every quiz answer right and it completes itself.

Something unclear, wrong or out of date in this lesson? Tell me, and I'll fix it.

← PreviousEBS, EFS and instance storeNext lesson →CloudFront: a fast edge in front of your app