4

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?

JonoB
  • 273
  • 1
  • 3
  • 9
  • How stuck are you on the current DNS provider? You could run a little microservice that just redirects non-www to www, I suppose. – ceejayoz Feb 19 '18 at 21:25

1 Answers1

5

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.

Tim
  • 31,888
  • 7
  • 52
  • 78
  • I understand that, but as I outlined above, I have no idea how to point my A record to Route 53? Doesn't an A record have to point to an IP address? In which case, what IP address am I pointing to? Note that my domain is hosted at a different registrar – JonoB Feb 19 '18 at 21:49
  • 1
    You don't point an A record at Route 53. You'd use the Route 53 nameservers. This would affect the entire domain. – ceejayoz Feb 19 '18 at 21:49
  • What ceejayoz said. Answer updated. – Tim Feb 19 '18 at 21:53
  • So I have to migrate the nameservers to Route 53 as per https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/migrate-dns-domain-in-use.html ? – JonoB Feb 19 '18 at 22:00
  • Yes, that's the best option. – Tim Feb 19 '18 at 22:15
  • 2
    Note that Cloudflare's implementation **does not** violate the standard, because the answer isn't returned as a CNAME. They proxy a query out the back door for the real A/AAAA record, and return whatever value is found in the response they receive. https://support.cloudflare.com/hc/en-us/articles/200169056-CNAME-Flattening-RFC-compliant-support-for-CNAME-at-the-root – Michael - sqlbot Feb 20 '18 at 00:13