How do I create alias records for services hosted in AWS?

4 minute read
0

I want to create custom DNS records for AWS-hosted services, and I want to know what type of alias record to use.

Short description

Amazon Route 53 alias records map internally to the DNS name of alias targets, such as AWS resources. Route 53 monitors the IP address associated with an alias target's DNS name for scaling actions and software updates. Route 53 name servers respond with an A record (IPv4 addresses) or AAAA record (IPv6 addresses) with the IP address of the alias target.

Resolution

Create an alias record

Create your record in the Route 53 console and specify the necessary values for alias records.

Be sure to use the correct DNS record type for IP addresses in the service you're pointing to:

  • Amazon CloudFront distribution: A record (IPv4) or AAAA record (IPv6)
  • AWS Elastic Beanstalk environment: A record (IPv4)
  • Elastic Load Balancing load balancer: A record (IPv4) or AAAA record (IPv6)
  • Amazon Simple Storage Service (Amazon S3) bucket: A record (IPv4)
  • Amazon API Gateway custom Regional API and edge-optimized API: A record (IPv4)
  • Amazon VPC interface endpoint: A record (IPv4)
  • AWS Global Accelerator: A record (IPv4)
  • AWS AppSync: A record (IPv4)
  • AWS App Runner: A record (IPv4)
  • Another Route 53 record in the same hosted zone

Note: Some services require you to set up a custom DNS name before creating the record. These services include Amazon API Gateway and Amazon CloudFront.

CNAME support

Route 53 follows the pointer in an alias record only if the record type matches. To create an alias record for a CNAME record, the alias target must resolve to a CNAME value.

Even if you create a CNAME(ALIAS) record that's not valid, Route 53 can't resolve the IP address of the endpoint. As a result, Route 53 returns an SERVFAIL/REFUSED RCODE error.

Valid CNAME(ALIAS) record

NameTypeValue
cname.example.com.CNAME(ALIAS)cname1.example.com.
cname1.example.com.CNAMEabc.example.net.
abc.example.net.A203.0.113.1

Not valid CNAME(ALIAS) record

NameTypeValue
cname.example.com.CNAME(ALIAS)d12345xx.cloudfront.net.
cname.example.com.CNAME(ALIAS)dualstack.elb123.us-east 1.elb.amazonaws.com.
cname.example.com.CNAME(ALIAS)s3-website-us-west-2.amazonaws.com.
cname.example.com.CNAME(ALIAS)ebs1234.us-east-1.elasticbeanstalk.com.

Point from non-Route 53 DNS providers

If you use a DNS provider other than Route 53 for your domain, then you might be able to point the domain to AWS services. Check if your DNS provider supports CNAME records on a root domain. To do this, use techniques such as CNAME flattening, ANAME records, or WebHops Redirect.

Considerations for creating CNAME records

  1. You can't create a CNAME record for the Parent, Naked, or Apex domain. With Route 53, you can use an alias record to point the parent domain to other supported alias targets. For example, if you create a hosted zone for the domain example.com, then you can't create the following CNAME record:

    example.com CNAME dualstack.elb123.us-east 1.elb.amazonaws.com.

    If you create a hosted zone for the domain www.example.com, then you can't create the following CNAME record:

    www.example.com CNAME dualstack.elb123.us-east 1.elb.amazonaws.com.

    With Route 53, you can create an alias record instead:

    example.com Alias(A) dualstack.elb123.us-east 1.elb.amazonaws.com.
  2. CNAME records can't coexist with other record types for the same domain in the hosted zone file. For example, you can have only one record type for the domain example.com if the record type is CNAME. You can't create the following record:

    abc.example.com CNAME www.example.comabc.example.com A     54.239.28.85
  3. You can create a wildcard record that can coexist with the CNAME record:

    abc.example.com CNAME www.example.com*.example.com   A     54.239.28.85

Related information

Why can't I select my preferred alias target when creating a Route 53 alias resource record set?

AWS OFFICIAL
AWS OFFICIALUpdated 6 months ago