How do I create alias records for services hosted in AWS?
Last updated: 2021-05-19
I am creating custom DNS records for services hosted on AWS. What type of alias record should I use?
Amazon Route 53 alias records are mapped 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. The authoritative response from Route 53 name servers contains an A record (for IPv4 addresses) or AAAA record (for IPv6 addresses) with the IP address of the alias target.
Create an alias record
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 (ELB) 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)
- Another Route 53 record in the same hosted zone
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 an invalid CNAME(ALIAS) record, 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:
Invalid CNAME(ALIAS) record:
Pointing from non-Route 53 DNS providers
If you use a DNS provider other than Route 53 for your domain name, then you might be able to point the domain to services hosted on AWS. Check if your DNS provider supports CNAME records on a root domain using techniques such as CNAME flattening, ANAME records, or WebHops redirection.
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 created 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 created 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. For example:
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.com abc.example.com A 184.108.40.206
3. You can create a wildcard record that can coexist with the CNAME record. For example:
abc.example.com CNAME www.example.com *.example.com A 220.127.116.11