EC2/Route53: How do I assign my new domain name to an instance?
I have an EC2 instance. It's up and running with an Amazon IP that looks something like this: //ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/
I am sure it works fine.
I bought a domain and then set up a "Hosted Zone" in Amazon Route 53 and it gave me some name server info once I did. I went to my domain registrar and put those names into the name servers.
Now I'm stuck. How do I associate this Hosted Zone with my instance? I'd like Amazon to host so that's fine.
If you're using the AWS console, then you can associate your desired hostname (e.g., www.example.com) with the IP address of the EC2 instance using a CNAME record to the external DNS name for the instance.
For example:
Navigate to the hosted zone you created (double click works)
Click [Create Record Set] at top
Name: www.example.com
Type: CNAME
Value: ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com.
Click [Create Record Set] at the bottom of the form
I also recommend you learn about Elastic IP addresses. You should allocate an elastic IP address, associate it with your instance, and then map the CNAME to the new external DNS name for the Elastic IP address on your instance. This will let you move the Elastic IP address between instances without having to update your DNS.
If you're curious why I recommend a CNAME instead of using an A record, here's a benefit I wrote about when talking between instances inside EC2: http://alestic.com/2009/06/ec2-elastic-ip-internal
Well for me it was pretty easy. I had 2 separate situations where I needed to assign my domain name to instances:
- In the first case, I had a 6 web-servers behind a single load balancer. And I wanted to assign it my root domain, let's say: mydomain.com I simple updated dNS for mydomain.com and instead of creating an A record, I assigned a CNAME for mydomain.com (yes the domain root), pointing to the Public DNS of the load balancer.
- In another instance, I had a single web-server. There also I created a CNAME of the domain pointing to the Public DNS of the web-server itself.
Its exactly similar to how you create CNAME records to point to ghs.google.com when using Google Apps.
Better option is to assign an Elastic IP address to your instance. Once allocated, Create a "A" record in your hosted zone and add your instances Elastic IP as the value. This will point your domain name to the instance.
For detailed instruction, you can follow this blog. http://comtechies.com/2016/07/point-map-domain-name-aws-ec2-server.html