Bird
Raised Fist0
AWScloud~5 mins

Record types (A, AAAA, CNAME, Alias) in AWS - Commands & Configuration

Choose your learning style10 modes available
Introduction
When you want to connect your website or app to the internet, you need to tell the internet where to find it. Record types like A, AAAA, CNAME, and Alias help map your domain name to the right place, like an IP address or another domain.
When you want your domain name to point to a server's IPv4 address using an A record.
When you want your domain name to point to a server's IPv6 address using an AAAA record.
When you want your domain name to point to another domain name using a CNAME record.
When you want to point your domain to AWS resources like CloudFront or an Elastic Load Balancer using an Alias record.
Config File - route53-records.json
route53-records.json
{
  "Comment": "Create records for example.com",
  "Changes": [
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com.",
        "Type": "A",
        "TTL": 300,
        "ResourceRecords": [
          {"Value": "192.0.2.1"}
        ]
      }
    },
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "example.com.",
        "Type": "AAAA",
        "TTL": 300,
        "ResourceRecords": [
          {"Value": "2001:db8:85a3::8a2e:370:7334"}
        ]
      }
    },
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "www.example.com.",
        "Type": "CNAME",
        "TTL": 300,
        "ResourceRecords": [
          {"Value": "example.com."}
        ]
      }
    },
    {
      "Action": "CREATE",
      "ResourceRecordSet": {
        "Name": "alias.example.com.",
        "Type": "A",
        "AliasTarget": {
          "HostedZoneId": "Z2FDTNDATAQYW2",
          "DNSName": "d123.cloudfront.net.",
          "EvaluateTargetHealth": false
        }
      }
    }
  ]
}

This JSON file is used with AWS Route 53 to create DNS records.

  • A record: Points example.com to an IPv4 address.
  • AAAA record: Points example.com to an IPv6 address.
  • CNAME record: Points www.example.com to example.com.
  • Alias record: Points alias.example.com to an AWS CloudFront distribution using its DNS name and hosted zone ID.
Commands
This command applies the DNS record changes defined in the JSON file to the specified hosted zone in Route 53.
Terminal
aws route53 change-resource-record-sets --hosted-zone-id Z3P5QSUBK4POTI --change-batch file://route53-records.json
Expected OutputExpected
{ "ChangeInfo": { "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2024-06-01T12:00:00Z", "Comment": "Create records for example.com" } }
→
--hosted-zone-id - Specifies the Route 53 hosted zone where the records will be created.
→
--change-batch - Specifies the JSON file with the record changes.
This command lists all DNS records in the hosted zone to verify that the new records were created successfully.
Terminal
aws route53 list-resource-record-sets --hosted-zone-id Z3P5QSUBK4POTI
Expected OutputExpected
{ "ResourceRecordSets": [ { "Name": "example.com.", "Type": "A", "TTL": 300, "ResourceRecords": [ {"Value": "192.0.2.1"} ] }, { "Name": "example.com.", "Type": "AAAA", "TTL": 300, "ResourceRecords": [ {"Value": "2001:db8:85a3::8a2e:370:7334"} ] }, { "Name": "www.example.com.", "Type": "CNAME", "TTL": 300, "ResourceRecords": [ {"Value": "example.com."} ] }, { "Name": "alias.example.com.", "Type": "A", "AliasTarget": { "HostedZoneId": "Z2FDTNDATAQYW2", "DNSName": "d123.cloudfront.net.", "EvaluateTargetHealth": false } } ] }
→
--hosted-zone-id - Specifies the hosted zone to list records from.
Key Concept

If you remember nothing else from this pattern, remember: DNS record types tell the internet how to find your domain, whether by IP address, another domain, or AWS resources.

Common Mistakes
Using a CNAME record for the root domain (example.com) instead of a CNAME for subdomains.
DNS standards do not allow CNAME records at the root domain, which can cause resolution failures.
Use A or Alias records for the root domain and CNAME records only for subdomains like www.
Setting TTL too low or too high without understanding impact.
Too low TTL causes excessive DNS queries; too high delays updates propagation.
Use a balanced TTL like 300 seconds for typical use.
Not using Alias records for AWS resources like CloudFront or ELB.
Alias records allow AWS to manage IP changes automatically; without them, your DNS may break if IPs change.
Use Alias records pointing to AWS resource DNS names with correct hosted zone IDs.
Summary
Create DNS records using a JSON file with A, AAAA, CNAME, and Alias types for different purposes.
Apply the DNS changes to Route 53 using the AWS CLI change-resource-record-sets command.
Verify the records were created correctly by listing them with the AWS CLI.

Practice

(1/5)
1. Which DNS record type is used to link a domain name to an IPv4 address?
easy
A. A record
B. AAAA record
C. CNAME record
D. Alias record

Solution

  1. Step 1: Understand the purpose of A records

    A records map domain names directly to IPv4 addresses, which are 4-byte numeric addresses.
  2. Step 2: Compare with other record types

    AAAA records map to IPv6, CNAME to other domain names, and Alias to AWS resources without extra cost.
  3. Final Answer:

    A record -> Option A
  4. Quick Check:

    IPv4 address mapping = A record [OK]
Hint: IPv4 addresses use A records, not AAAA or CNAME [OK]
Common Mistakes:
  • Confusing A record with AAAA record
  • Thinking CNAME points to IP addresses
  • Assuming Alias records map to IPs
2. Which of the following is the correct syntax for creating a CNAME record in AWS Route 53?
easy
A. example.com Alias my-load-balancer.amazonaws.com
B. example.com CNAME www.example.com
C. example.com AAAA 2001:db8::1
D. example.com A 192.0.2.1

Solution

  1. Step 1: Identify CNAME record syntax

    CNAME records map one domain name to another domain name, so the value must be a domain, not an IP.
  2. Step 2: Check each option

    example.com CNAME www.example.com correctly shows a domain pointing to another domain. The other options use either IP addresses (A/AAAA records) or Alias syntax (for AWS resources).
  3. Final Answer:

    example.com CNAME www.example.com -> Option B
  4. Quick Check:

    CNAME points domain to domain [OK]
Hint: CNAME value must be a domain name, not an IP [OK]
Common Mistakes:
  • Using IP address as CNAME target
  • Confusing Alias syntax with CNAME
  • Mixing A and CNAME record formats
3. Given the following Route 53 records:
www.example.com CNAME example.com
example.com A 192.0.2.10
What IP address will www.example.com resolve to?
medium
A. example.com
B. www.example.com
C. 192.0.2.10
D. 192.0.2.20

Solution

  1. Step 1: Understand CNAME resolution

    CNAME points www.example.com to example.com, so DNS looks up example.com next.
  2. Step 2: Find example.com's A record

    example.com has an A record pointing to 192.0.2.10, so www.example.com resolves to this IP.
  3. Final Answer:

    192.0.2.10 -> Option C
  4. Quick Check:

    CNAME follows to A record IP [OK]
Hint: CNAME points to domain, then resolve that domain's A record [OK]
Common Mistakes:
  • Thinking CNAME returns domain name, not IP
  • Ignoring chained resolution of CNAME to A record
  • Assuming CNAME resolves directly to IP
4. You created an Alias record in Route 53 pointing to an AWS Elastic Load Balancer, but DNS queries return NXDOMAIN errors. What is the most likely cause?
medium
A. CNAME records must be used instead of Alias
B. Alias records cannot point to AWS resources
C. Alias records require an IP address target
D. The Alias target is incorrect or misspelled

Solution

  1. Step 1: Understand Alias record usage

    Alias records can point to AWS resources like Elastic Load Balancers without extra cost.
  2. Step 2: Identify common misconfiguration

    If DNS returns NXDOMAIN, the Alias target is likely incorrect or misspelled, causing failure to resolve.
  3. Final Answer:

    The Alias target is incorrect or misspelled -> Option D
  4. Quick Check:

    Alias target must be correct AWS resource name [OK]
Hint: Check Alias target spelling and correctness first [OK]
Common Mistakes:
  • Thinking Alias can't point to AWS resources
  • Using IP address as Alias target
  • Confusing Alias with CNAME requirements
5. You want to route traffic for app.example.com to an AWS CloudFront distribution without incurring extra DNS query charges. Which record type should you use in Route 53?
hard
A. Alias record pointing to CloudFront distribution
B. AAAA record pointing to CloudFront IPv6 address
C. CNAME record pointing to CloudFront domain
D. A record with CloudFront IP address

Solution

  1. Step 1: Understand DNS charges and AWS Alias records

    Alias records in Route 53 allow pointing to AWS resources like CloudFront without extra DNS query charges.
  2. Step 2: Evaluate options for CloudFront routing

    AAAA requires IPv6 addresses which CloudFront does not provide; A record with IP is not possible as CloudFront IPs are dynamic; CNAME works but incurs charges; Alias is best for AWS resources.
  3. Final Answer:

    Alias record pointing to CloudFront distribution -> Option A
  4. Quick Check:

    Alias avoids extra DNS charges for AWS targets [OK]
Hint: Use Alias for AWS resources to avoid extra DNS costs [OK]
Common Mistakes:
  • Using CNAME and paying extra DNS charges
  • Trying to use IP addresses for CloudFront
  • Not knowing Alias supports CloudFront
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