DevOps.Academy
CoursesCurriculumPricing

    Loading…

    ↑ ↓ move · ↵ open · Ctrl K anywhere

    ◔My learningSign in
    DevOps.Academy

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

    Learn

    All coursesLinux roadmapCurriculumMy 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

    DNS turns a name like api.example.com into an address a computer can connect to. Route 53 is AWS's DNS service: it hosts your DNS records, answers queries from anywhere in the world, health-checks endpoints and can register domains. The name comes from DNS's port, 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.

    Hosted zones

    A hosted zone holds the records for one domain:

    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).

    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

    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.

    Domain registration

    Registered domains → Register domains buys a domain through Route 53 and creates its public hosted zone for you. If your domain is registered elsewhere, create a public hosted zone and set the registrar's name servers to the four in its NS record. Registration costs real money and renews yearly, so it's never part of a practice mission.

    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.

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