How do I create a subdomain for my domain that's hosted in Route 53?

3 minute read
4

I want to create a subdomain for my domain that's hosted in Amazon Route 53, but I don't know how.

Short description

Using a separate hosted zone to route internet traffic for a subdomain is known as delegating responsibility for a subdomain to a hosted zone. It might also be referred to as subdomain delegation through name servers.

Prerequisites

Before you begin, be sure to implement the following requirements:

  • A valid registered domain (regardless of the registrar)
  • An authoritative hosted zone for the registered domain in Route 53

Resolution

Create a hosted zone for the subdomain in Route 53

Create a hosted zone with the same name as the subdomain that you want to route traffic for, such as acme.example.com. To do this, complete the following steps:

  1. Open the Route 53 console.
  2. In the navigation pane, choose Hosted zones.
  3. Choose Create hosted zone.
  4. In the navigation pane, enter the name of the subdomain (such as acme.example.com).
    Note: For more information, see DNS domain name format.
  5. For Type, accept the default value of Public hosted zone.
  6. Choose Create hosted zone.

Find the name servers that Route 53 assigned to the new hosted zone

When you create a hosted zone, Route 53 automatically assigns four name servers to the zone. To start using the hosted zone for the subdomain, create a new name server (NS) record in the hosted zone for the domain (example.com). The name of the NS record must be the same as the name of the subdomain (acme.example.com).

After creating the hosted zone for the subdomain, expand the Hosted zone details dropdown list for the subdomain in the hosted zone (acme.example.com). In the right pane, copy the names of the four servers listed as the Name servers under Hosted zone details.

Add NS records to route traffic to your subdomain

Complete the following steps to route traffic to your subdomain. These steps also apply to cross-account scenarios where the hosted zone for the domain and the subdomain are in different accounts.

  1. Select the hosted zone for the domain (example.com). Be sure not to select the name of the subdomain (some.example.com).
  2. In the hosted zone for the domain, choose Create record.
  3. For Name, enter the name of the subdomain.
  4. For Value, enter the names of the name servers.
  5. For Record type, choose NS - Name servers for a hosted zone.
  6. For TTL (Seconds), select a more common value for an NS record, such as 172,800 seconds.
  7. For Route Policy, choose Simple routing.
  8. Choose Create Records.

Note: To remove the subdomain delegation (acme.example.com), first delete the NS record in the parent hosted zone (example.com). Then, delete the subdomain hosted zone. These steps protect your subdomain from an unauthorized takeover.

Create records in the subdomain hosted zone

Create your records in the newly-created subdomain hosted zone. Test the record resolution using the dig/nslookup command.

Example dig/nslookup command:

dig acme.example.com

AWS OFFICIAL
AWS OFFICIALUpdated a year ago
2 Comments

Informative and Comprehensive Thank You.

Nafiu
replied 8 months ago

Simple and helpful.

Lily
replied 21 days ago