Bird
Raised Fist0
AWScloud~5 mins

Hosted zones concept in AWS - Commands & Configuration

Choose your learning style10 modes available
Introduction
When you want to connect your website or app to a domain name, you need a way to tell the internet where to find it. Hosted zones help you manage the settings that link your domain name to your servers or services.
When you buy a domain name and want to point it to your website hosted on AWS.
When you need to manage DNS records like A, CNAME, or MX for your domain.
When you want to create subdomains like blog.example.com or shop.example.com.
When you want to route traffic to different AWS resources like load balancers or S3 buckets.
When you want to keep your domain's DNS settings organized and secure within AWS.
Commands
This command creates a new hosted zone for the domain example.com. The caller reference is a unique string to identify this request.
Terminal
aws route53 create-hosted-zone --name example.com --caller-reference 20240601120000
Expected OutputExpected
{ "HostedZone": { "Id": "/hostedzone/Z1D633PJN98FT9", "Name": "example.com.", "CallerReference": "20240601120000", "Config": { "PrivateZone": false }, "ResourceRecordSetCount": 2 }, "ChangeInfo": { "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2024-06-01T12:00:00Z" } }
→
--name - Specifies the domain name for the hosted zone.
→
--caller-reference - A unique string to identify the request and avoid duplicates.
This command lists all hosted zones in your AWS account to verify the new hosted zone was created.
Terminal
aws route53 list-hosted-zones
Expected OutputExpected
{ "HostedZones": [ { "Id": "/hostedzone/Z1D633PJN98FT9", "Name": "example.com.", "CallerReference": "20240601120000", "Config": { "PrivateZone": false }, "ResourceRecordSetCount": 2 } ] }
This command adds an A record to the hosted zone, pointing www.example.com to the IP address 192.0.2.44.
Terminal
aws route53 change-resource-record-sets --hosted-zone-id Z1D633PJN98FT9 --change-batch '{"Changes":[{"Action":"CREATE","ResourceRecordSet":{"Name":"www.example.com.","Type":"A","TTL":300,"ResourceRecords":[{"Value":"192.0.2.44"}]}}]}'
Expected OutputExpected
{ "ChangeInfo": { "Id": "/change/C2RDJXEXAMPLE", "Status": "PENDING", "SubmittedAt": "2024-06-01T12:05:00Z" } }
→
--hosted-zone-id - Specifies which hosted zone to update.
→
--change-batch - Defines the DNS record changes to apply.
This command lists all DNS records in the hosted zone to confirm the new record was added.
Terminal
aws route53 list-resource-record-sets --hosted-zone-id Z1D633PJN98FT9
Expected OutputExpected
{ "ResourceRecordSets": [ { "Name": "example.com.", "Type": "NS", "TTL": 172800, "ResourceRecords": [ {"Value": "ns-2048.awsdns-64.com."}, {"Value": "ns-2049.awsdns-65.net."}, {"Value": "ns-2050.awsdns-66.org."}, {"Value": "ns-2051.awsdns-67.co.uk."} ] }, { "Name": "example.com.", "Type": "SOA", "TTL": 900, "ResourceRecords": [ {"Value": "ns-2048.awsdns-64.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"} ] }, { "Name": "www.example.com.", "Type": "A", "TTL": 300, "ResourceRecords": [ {"Value": "192.0.2.44"} ] } ] }
→
--hosted-zone-id - Specifies which hosted zone's records to list.
Key Concept

If you remember nothing else from this pattern, remember: a hosted zone is where you manage all the DNS settings for your domain in AWS.

Common Mistakes
Using the wrong hosted zone ID when adding or listing DNS records.
The commands will fail or update the wrong domain's settings, causing your website to be unreachable.
Always copy the hosted zone ID exactly from the create or list command output before making changes.
Not waiting for DNS changes to propagate after updating records.
Your changes may not be visible immediately, leading to confusion or downtime.
Allow some time (usually a few minutes) for DNS changes to take effect and verify with the list command.
Summary
Create a hosted zone to manage your domain's DNS settings in AWS.
Add DNS records like A records to point subdomains to IP addresses.
List hosted zones and records to verify your DNS configuration.

Practice

(1/5)
1. What is the main purpose of a hosted zone in AWS Route 53?
easy
A. To manage DNS records for a specific domain
B. To store website files
C. To host virtual machines
D. To monitor network traffic

Solution

  1. Step 1: Understand the role of hosted zones

    Hosted zones are containers for DNS records that belong to a domain.
  2. Step 2: Identify what hosted zones manage

    They manage DNS records, which connect domain names to IP addresses or other resources.
  3. Final Answer:

    To manage DNS records for a specific domain -> Option A
  4. Quick Check:

    Hosted zone = DNS management [OK]
Hint: Hosted zones manage DNS records, not files or servers [OK]
Common Mistakes:
  • Confusing hosted zones with web hosting
  • Thinking hosted zones store website content
  • Assuming hosted zones monitor traffic
2. Which of the following is the correct way to create a public hosted zone in AWS CLI?
easy
A. aws route53 create-hosted-zone --name example.com --caller-reference 12345 --hosted-zone-config PrivateZone=true
B. aws route53 create-hosted-zone --name example.com --caller-reference 12345 --hosted-zone-config PrivateZone=false,VPCId=vpc-12345678,Region=us-east-1
C. aws route53 create-hosted-zone --name example.com --caller-reference 12345
D. aws route53 create-hosted-zone --domain example.com --private false

Solution

  1. Step 1: Review AWS CLI syntax for creating hosted zones

    The basic command requires --name and --caller-reference; --hosted-zone-config is optional.
  2. Step 2: Identify correct public hosted zone creation

    Omitting --hosted-zone-config creates a public hosted zone by default.
  3. Final Answer:

    aws route53 create-hosted-zone --name example.com --caller-reference 12345 -> Option C
  4. Quick Check:

    Default is public hosted zone [OK]
Hint: No PrivateZone flag means public hosted zone by default [OK]
Common Mistakes:
  • Setting PrivateZone=true creates private zone, not public
  • Using incorrect parameter names like --domain
  • Omitting required --caller-reference
3. Given the following Route 53 hosted zone configuration, what will happen if you create an A record pointing to an IP address?
Hosted Zone: example.com
Record Name: www.example.com
Record Type: A
Value: 192.0.2.44
medium
A. The record will redirect to example.com automatically
B. www.example.com will resolve to the IP 192.0.2.44
C. The record will cause a DNS error
D. www.example.com will resolve to the hosted zone ID

Solution

  1. Step 1: Understand A record function

    An A record maps a domain name to an IPv4 address.
  2. Step 2: Apply to given record

    The record www.example.com with type A and value 192.0.2.44 means it resolves to that IP.
  3. Final Answer:

    www.example.com will resolve to the IP 192.0.2.44 -> Option B
  4. Quick Check:

    A record maps domain to IP [OK]
Hint: A record points domain to IPv4 address directly [OK]
Common Mistakes:
  • Confusing A record with hosted zone ID
  • Expecting automatic redirects from DNS
  • Assuming DNS error without syntax issues
4. You created a private hosted zone but your EC2 instances cannot resolve the domain names inside it. What is the most likely cause?
medium
A. The private hosted zone is not associated with the VPC
B. The hosted zone is public instead of private
C. The domain name is misspelled in the record
D. The EC2 instances do not have internet access

Solution

  1. Step 1: Understand private hosted zone requirements

    Private hosted zones must be linked to one or more VPCs to work.
  2. Step 2: Identify why EC2 can't resolve names

    If the private hosted zone is not associated with the VPC where EC2 runs, DNS queries fail.
  3. Final Answer:

    The private hosted zone is not associated with the VPC -> Option A
  4. Quick Check:

    Private hosted zone needs VPC association [OK]
Hint: Private hosted zones must link to VPCs to resolve names [OK]
Common Mistakes:
  • Assuming public/private mix-up causes resolution failure
  • Ignoring VPC association requirement
  • Thinking internet access affects private DNS resolution
5. You want to host a website on AWS and use a custom domain. Which steps correctly describe how to use a hosted zone to make your website accessible via your domain?
hard
A. Create a private hosted zone, add DNS records, and update your domain registrar to use Route 53 name servers
B. Create a hosted zone, configure EC2 security groups, and update your domain registrar
C. Create a public hosted zone, upload website files to Route 53, and update your domain registrar
D. Create a public hosted zone for your domain, add DNS records pointing to your website's IP or load balancer, then update your domain registrar to use Route 53 name servers

Solution

  1. Step 1: Choose hosted zone type for public website

    A public hosted zone is needed to make the domain accessible on the internet.
  2. Step 2: Add DNS records pointing to website

    Add A or CNAME records pointing to your website's IP or load balancer.
  3. Step 3: Update domain registrar with Route 53 name servers

    Set your domain's name servers to those provided by Route 53 to route traffic correctly.
  4. Final Answer:

    Create a public hosted zone for your domain, add DNS records pointing to your website's IP or load balancer, then update your domain registrar to use Route 53 name servers -> Option D
  5. Quick Check:

    Public hosted zone + DNS records + registrar update = website access [OK]
Hint: Public hosted zone + DNS records + registrar update = website online [OK]
Common Mistakes:
  • Using private hosted zone for public website
  • Thinking Route 53 hosts website files
  • Skipping domain registrar name server update
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard