0
0
AwsHow-ToBeginner · 3 min read

How to Create a Hosted Zone in AWS Route 53

To create a hosted zone in AWS Route 53, use the create-hosted-zone command with your domain name and caller reference. This sets up DNS management for your domain in Route 53.
📐

Syntax

The basic syntax to create a hosted zone in AWS Route 53 using AWS CLI is:

  • --name: The domain name for the hosted zone.
  • --caller-reference: A unique string to identify the request.
  • --hosted-zone-config: Optional settings like comment and private zone flag.
bash
aws route53 create-hosted-zone --name example.com --caller-reference 20240627120000
💻

Example

This example creates a public hosted zone for the domain example.com using AWS CLI. The caller-reference is a timestamp to ensure uniqueness.

bash
aws route53 create-hosted-zone --name example.com --caller-reference 20240627120000
Output
{ "HostedZone": { "Id": "/hostedzone/Z1D633PJN98FT9", "Name": "example.com.", "CallerReference": "20240627120000", "Config": { "Comment": "", "PrivateZone": false }, "ResourceRecordSetCount": 2 }, "ChangeInfo": { "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2024-06-27T12:00:00Z" }, "DelegationSet": { "NameServers": [ "ns-2048.awsdns-64.com", "ns-2049.awsdns-65.net", "ns-2050.awsdns-66.org", "ns-2051.awsdns-67.co.uk" ] } }
⚠️

Common Pitfalls

Common mistakes when creating a hosted zone include:

  • Using a non-unique caller-reference, which causes the request to be rejected.
  • Forgetting the trailing dot in the domain name when using APIs (CLI accepts without dot).
  • Trying to create a hosted zone for a domain not registered or not owned by you.
  • Confusing public and private hosted zones; private zones require a VPC ID.
bash
aws route53 create-hosted-zone --name example.com --caller-reference 12345

# Wrong: caller-reference not unique, may cause error

aws route53 create-hosted-zone --name example.com --caller-reference 12345

# Right: use unique timestamp or UUID
aws route53 create-hosted-zone --name example.com --caller-reference 20240627120000
📊

Quick Reference

Summary tips for creating hosted zones in Route 53:

  • Always use a unique caller-reference (timestamp or UUID).
  • Use --hosted-zone-config to add comments or create private zones.
  • Check domain ownership before creating a hosted zone.
  • Use AWS Management Console or SDKs as alternatives to CLI.

Key Takeaways

Use the AWS CLI command create-hosted-zone with your domain name and a unique caller reference to create a hosted zone.
Ensure the caller reference is unique to avoid request rejection.
Choose between public and private hosted zones depending on your DNS needs.
Verify domain ownership before creating a hosted zone to avoid errors.
You can also create hosted zones via AWS Console or SDKs for convenience.