0
0
AwsConceptBeginner · 3 min read

What is CNAME Record in Route 53: Simple Explanation and Example

A CNAME record in AWS Route 53 is a DNS setting that points one domain name to another domain name. It helps redirect traffic from an alias domain to the main domain without using an IP address directly.
⚙️

How It Works

Think of a CNAME record like a forwarding address for mail. Instead of delivering mail directly to a house, the post office sends it to another address where the mail is actually received. In DNS terms, when someone types your alias domain name, the CNAME record tells their browser to look up the main domain name instead.

This means the alias domain does not have its own IP address. Instead, it borrows the IP address of the main domain. This is useful because if the main domain's IP changes, you only update it in one place, and all alias domains automatically follow.

💻

Example

This example shows how to create a CNAME record in Route 53 that points www.example.com to example.com. This means visitors typing www.example.com will be directed to the same site as example.com.

json
{
  "Comment": "Create CNAME record for www.example.com",
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "www.example.com.",
        "Type": "CNAME",
        "TTL": 300,
        "ResourceRecords": [
          {
            "Value": "example.com."
          }
        ]
      }
    }
  ]
}
Output
CNAME record created: www.example.com points to example.com
🎯

When to Use

Use a CNAME record when you want multiple domain names to lead to the same website or service without managing separate IP addresses. For example:

  • Pointing www subdomain to the root domain.
  • Redirecting multiple brand domains to a single main domain.
  • Using third-party services like content delivery networks (CDNs) or hosted platforms where the target domain may change IPs.

Note: You cannot use a CNAME record on the root domain itself (like example.com), only on subdomains.

Key Points

  • A CNAME record maps one domain name to another domain name.
  • It helps manage domain aliases easily without IP address changes.
  • Cannot be used on the root domain; only on subdomains.
  • TTL controls how long DNS caches the record.

Key Takeaways

A CNAME record points one domain name to another domain name in Route 53.
Use CNAME for subdomains to alias them to a main domain or service.
CNAME records simplify DNS management by avoiding direct IP address use.
You cannot create a CNAME record for the root domain in Route 53.
TTL controls how long DNS resolvers cache the CNAME record.