How to connect your Amazon EC2 instance with a domain name

Yash Patel
3 min readSep 19, 2021

--

For this example, we are going to see how to connect a domain name to an Amazon EC2 instance.

You should already have your AWS (Amazon Web Services) account set up. If you do not have an account you can create one for free here.

Also, you would need an EC2 instance running. if you don't know how see setup EC2 instance please follow this link.

Setup 1: AWS side setup

  • Login to your AWS console and search Elastic IP. Click Allocate Elastic IP then Allocate. You can also provide an optional tag for your project.
  • Once Create click on the newly created IP and Action > Associate Elastic IP address
  • Choose the EC2 instance and leave the Private Ip Address blank and click Associate.
  • Copy the public Ipv4 address of your Ec2 instance this is gonna be used in further steps.
  • Now, search Route 53 and select hosted zone, and click create hosted zone
  • Put the domain name that you want to associate with the EC2 instance. and click create hosted zone.
  • Click create record > simple routing > create simple record. We define two records here for the first one select the options shown below. And enter your EC2 instance’s public Ipv4 address. For creating the second record add www in front of the site name and an an alias put your site name.

Once the records are created keep the tab open and open your domain provider window.

Step 2: Domain Provider Setup (GoDaddy)

  • log in to your GoDaddy account or any other domain registration service you have used and go to your DNS settings.
  • Choose manage Name servers and paste 4 values of type NS in your hosted zone in AWS, to your DNS management records.

Note : It will take a few hours to reflect the change on the internet so please be patient.

After few hours give it a try and your website should now be online.

--

--

Yash Patel

Software Developer. Extremely Curious | Often Wrong | Always Learning.