How to use external DNS in conjunction with an AWS Elastic Load Balancer

amazon ec2amazon-elbamazon-route53amazon-web-servicesdomain-name-system

I'm setting up an Application Elastic Load Balancer, and I have it pointing to a few EC2 instances. I'm now trying to get my head around how to set up the DNS, given that my DNS is hosted externally from AWS.

I understand that I can use the cname for my domain, so I can set up DNS records for www.example.com, foo.example.com (and any other sub-domain.example.com) and point those to my ELB which something like elb-123456789.eu-west-1.elb.amazonaws.com. So this is all fine.

However, for the apex record (example.com) I cannot use cname, and I must use an A record. As far as I can see (and I could be wrong on this), I need to use Route 53:

  • Create a hosted zone for example.com
  • Create a recordset inside that hosted zone for example.com, with a type of alias. For the alias target, I select the ELB from above
  • Click Save
  • ???

I have no idea how to now point my A record at my domain registrar to this Route 53 alias.

Or am I meant to be doing something completely different?

Best Answer

DNS standards say you can't have a CNAME at the domain Apex, you need an A record.

Some providers will let you do this against standards. CloudFlare does this in a tricky way, it appears to let you create a CNAME at the domain apex but does it in a way that's standards compliant using a proxy system - Michael explains it well below.

The best option is to use AWS Route53 and alias records. Route53 takes over the job of providing DNS for the domain, you no longer need your previous DNS provider.