Switching hosting from GoDaddy to AWS

amazon ec2amazon-web-servicesdomain-name-system

For the longest time, I've had GoDaddy host my website. I have a domain name that has been registered with GoDaddy and is currently hosted with them. I read this article and created a new hosted zone via Route 53 and then got the delegation set values and plugged the 4 values into GoDaddy as the nameservers. I know that this can take a few hours to take effect, but where do I specify which ec2 instance to use? I have several instances running on my AWS account, but only one has my code that's relevant to my website that I'm focused on.

Best Answer

The 4 values you got from Route53 are name servers - they provide the location of where your records are stored (i.e. with Route53). In Route53, you need to have your actual A records. Previously, you (presumably) had one or more A records with GoDaddy which pointed to the elastic IP address of your EC2 instance, now, you need to recreate the same records in Route53 so that a lookup pointed to Route53 (which will be your new nameserver once the change propagates) will return the same record set that you previously had with GoDaddy.

When you access Route53, you get a list of your hosted zones: enter image description here

Select one of them and 'Go to Record Sets':

enter image description here

From there, create a new A record, that points at your elastic IP address.

Update to address your comment:

You have a website, it has some code that renders it. The question is, when I type in example.com into my browser, how do I get to view your code? My browser will do a DNS lookup starting with the root nameservers (.) (which it should already know) - these will provide a list of .com nameservers, where it can lookup the nameservers for example.com. Those nameservers will provide the IP address that can be used to access your code. Your browser then goes to that IP address, and passes a host header to specify which domain it is trying to access (for instance, there could be multiple domains on the same server).

In order to move from GoDaddy to AWS, you can a) just move your code to AWS (if you have a static website, move it to S3 instead of EC2), and point your GoDaddy DNS records at your new host (e.g. your EC2 instance's IP address). In EC2, your instance's IP address will change when the instance reboots, etc. As such it is a dynamic IP address, not well suited for hosting a website. Instead, you need to allocate a static IP address, once that can be assigned to an instance - AWS call this an 'Elastic IP'. This is what you will use for your A record. (The same holds true whether you use GoDaddy's DNS or Route53 - you need an A record that points to the IP address of your server - but there is no requirement to use Route53 just because you are using AWS to host your site - there are some exceptions - e.g. using an elastic load balancer).

enter image description here

Related Topic