Connecting a Domain to an AWS EC2 Instance Using Route53

Paul Soniat
Frontend Weekly
Published in
4 min readJan 31, 2018

I, and my team, are currently working on an photo recognition scavenger hunt app. I was tasked to connect the domain to our Amazon instance. At first I was excited, this was my first deep dive into connection to domains. However, I quickly got frustrated by contradictions in “How-To” guides. You can now visit our site at https://venari.us and try out a challenge for yourself. A security guide may be coming soon as well. However, the lack of guides online inspired me to write this guide.

For starters, all you need is a domain. I used GoDaddy to buy mine for a reasonable price, $7.99, and in this tutorial I will use an Amazon Web Service EC2 Ubuntu 16.04 instance and AWS route 53 as an example of how I connected my instance to the domain. An entire tutorial, and there are some, on how to set up an EC2 instance can be found online.. so I’m just gonna assume for this tutorial that one is made as well as a Route53 hosted zone (also very easy to create).

You can start by configuring your allowed routes on your EC2 instance. Mine are set up as follows

You should protect your SSH port to a per-ip basis, in case your SSH keys ever get compromised. This adds an extra layer of security

Port 80 is open http, 443 is https, SSH will come from 22.

Next, you need to find your IP for your instance, you can use Amazon’s EC2 GUI to view your instance. At the top right of the Description tab you will see a Public DNS and a IPv4 Public IP. Grab the IPv4 Public IP, this is how you will connect to your route 53 zone. You could also use an Elastic IP, as seen in the bottom left. An elastic IP is free, and also in case Amazon needs to take the server for maintenance, your A record IP will switch but an elastic IP will not. However, for this tutorial I am just using the provided IPv4 Public IP.

The second from the top on the right is what you need to grab, the arrow is pointing to it

Route 53 is a service to create hosted zones through amazon. In general I was very satisfied with their service. So drag along that copied IP and go to your hosted zone. Mine looks like this.

For this tutorial purposes, only concern yourself with the A and NS type certificates

So you can see that the IP copied over is in the value for my A type certificates.. I clicked on the top “Create Record Set” and made a type A record for venari.us and www.venari.us so a user could access both. Amazon issued me the NS values. These are called Name Servers, and they are important for the next step, connecting this hosted zone to GoDaddy.

As a quick recap, we have created an Ubuntu EC2 instance, and now have connected that instance, through IP, to our hosted zone.

Ok, off to GoDaddy.

Click your account, and then “Manage Domains”. Then on the list of domains, click the menu of the domain you want to connect and choose to “Manage DNS”, otherwise known as Domain name settings, for that domain.

Remember those Name Servers back from Route 53? It’s their time to shine.

Under DNS Management, you will be prompted to enter Name Servers,

Copy and Paste the four name servers from your Route 53 zone, and you are good to go.

We now need to connect to our EC2 shell through the terminal. Let’s go back to the EC2 instance GUI. Click the “Connect” button for your instance as shown above, and follow the instructions given, they are clear and easy to follow. That will give you a quest pem to download, and once downloaded on your computer, you can use the command given to get into your shell.

Once in the shell, if you have already connected a repo to your shell, start the server and you are good to go. If not, connect your repo to the shell and start your server.

Your website will now be found, through http, at the domain that you purchased through GoDaddy! Mine, again, can be found at www.venari.us

I hope this helps someone and saves them time that I could have used, I however did enjoy figuring it out. Soon will be an article on how to get your site secure once you have followed the steps in this article.

Stay coding, my friends.

--

--