16

I'm trying to point mydomain.eu to an AWS load balancer, which, by its nature, does not have a stable IP, so I think I'm supposed to point the A record to a subdomain at Amazon, but as far as I can tell the A record can only be an IP address, so I'm terribly confused at the moment.

What would the zone file look like for mydomain.eu where the A record and the www subdomain both point to, let's say, loadbalancer.mydomain.aws.com?

Elver Loho
  • 263
  • 1
  • 2
  • 5

2 Answers2

11

You can use an Alias record like described in http://aws.amazon.com/route53/faqs/:

Additionally, Route 53 offers ‘Alias’ records (a Route 53-specific virtual record). Alias records are used to map resource record sets in your hosted zone to Elastic Load Balancing instances. Alias records work like a CNAME record in that you can map one DNS name (mydomain.com) to another ‘target’ DNS name (elb1234.elb.amazonaws.com). They differ from a CNAME record in that they are not visible to resolvers. Resolvers only see the A record and the resulting IP address of the target record.

Next you can cname the domain like domain.com to www.domain.com using a CNAME(after you've pointed it using the Alias record), like:

www.domain.com CNAME TO domain.com

Also please note that in order to do this you'll need to move your zone to route53 so to do the Alias record. Most of the DNS providers unfortunately don't offer the ability to make such records for the domain name.

Logic Wreck
  • 1,420
  • 9
  • 8
7

From the AWS info page on Elastic Load Balancing:

Traffic to the DNS name provided by the Elastic Load Balancer is automatically distributed across your load balanced, healthy Amazon EC2 instances.

So in essence, Amazon provides you with a DNS name to map your records to. This would be using a CNAME record as opposed to an A record. The DNS name of the load balancer should not change therefore you never have to deal with IPs which as you point out might change.

EDIT:

AWS has always supported direct CNAME links to subdomains and wildcard subdomains for a root domain with simply CNAME records. So essentially it looks something like:

www.mydomain.com -> my-aws-01-elb.aws.amazon.com

Then for your root level domain you have two options, either setup DNS forwarding with your DNS host provider so that mydomain.com -> www.mydomain.com or utilize Amazon's Route 53 service to host your entire DNS zone and let them manage and setup the required records to get root-level domain support.

If you don't need root domain level support and using a subdomain such as sub.mydomain.com or www.mydomain.com then you can use simple CNAME records for everything.

Brent Pabst
  • 6,069
  • 2
  • 24
  • 36
  • If you are to use the zone name record, like you have zone abc.com, then a CNAME won't work and you will have to use and Alias record as stated in my answer in order to point abc.com to the ELB. – Logic Wreck Sep 04 '12 at 18:26
  • If you have a domainname that you need to point to the ELB, and it's similar to the zonename name, then you need to use an Alias record in order to point this domain to the ELB rather then a CNAME as a CNAME won't work in this case. – Logic Wreck Sep 04 '12 at 18:33
  • Actually he says the next: where the A record and the www subdomain both point to, let's say, loadbalancer.mydomain.aws.com - please check thus my update. if he'll want to point the domain itself he'll have to use the Alias record as stated. Also please note that most DNS providers don't allow CNAMEs for the domain name, only A records are allowed. – Logic Wreck Sep 04 '12 at 18:51
  • Well for instance godaddy doesn't and from what I've seen in my practice as a sysadmin a lot of people host their DNS zones there. – Logic Wreck Sep 04 '12 at 18:54
  • godaddy is *hardly* a gold standard… – MikeyB Sep 04 '12 at 19:08
  • I agree, godaddy is not a very good choice, but still many people do host their DNS,sites etc. there – Logic Wreck Sep 04 '12 at 20:52
  • in my case i have pointed cname and the domain https://example.com not working however http://example.com working fine please suggest me how i can make working https://example.com. – Ramesh Chand Aug 23 '17 at 06:14