How to Create an Elastic IP Address on AWS and Point Your Domain to it.

Lyle Okoth
7 min readJun 8, 2022

--

AWS Elastic IP, meets Route 53 plus Namecheap.

In this quick tutorial we will go through:

  • Creating an Elastic IP on Amazon using AWS Elastic Service
  • Create a Domain on Amazon using Route53
  • Point a domain on Namecheap to the domain on AWS and associate it to the elastic IP.

Introduction

When you create an EC2 instance on AWS, it comes with a public IP address but this tends to change over time. This is particularly not good especially if you wan to associate it with a domain such as your-name.com. To overcome this, you will need an elastic IP.

Step 1: Register a domain

Head on over to Namecheap and create an account. Click on the SIGN UP button and follow the steps to create an account:

Once you have an account, click on the Domains tab and then enter the domain name that you want to purchase, in this case twyle.com:

If it’s available, add it to cart. The rest of the steps just involve checking out the cart. You will need either a credit card or PayPal account to make the purchase.

Step 2: Create an elastic IP Address on AWS using AWS Elastic IP

Log into your AWS account. First, let us confirm that the instance that you created has no elastic IP address associated with it.On the instances dashboard, select the checkbox next to the EC2 instance that you want to create the elastic IP address for. In this case, our instance is called EC2:

Select the Details tab:

Then Under the Instance summary, scroll down to the Elastic IP addresses section; it should be empty:

In the same tab in the navigation panel to the left:

Scroll down to the Network and Security section; within the drop-down, select Elastic IPs:

Click on the Allocate Elastic IP address button:

Leave the defaults and click on Allocate:

Then select the Associate this Elastic IP address prompt:

Select the instance to associate it with in the Instance drop-down, then in the Private IP address drop-down, select the instance’s private IP address. then click the Associate button:

And with that, we have successfully allocated an Elastic IP address to our EC2 server:

Step 3: Create a Domain on AWS using Route 53

To associate your newly purchased domain name with your newly created elastic IP address, you will need to create a domain on AWS using the AWS Route 53 service. To access the Route 53 service, just search for it in the search bar the top of the page:

On the resulting page, under DNS management, click on the Create hosted zone button:

In the Domain name field, enter your domain name, leave the others as default and click on the Create hosted zone button:

Next, we will create three CNAME records and one A record. All of them will point to the elastic address we just created, but later on I will modify them:

  • dev.twyle.xyz will be an A record that points to this server; I use it as a development server.
  • stage.twyle.xyz will be a CNAME record that initially points to this server but later on will point to a staging server address.
  • prod.twyle.xyz will also be a CNAME record that will point to a production server later on, but at the moment, it will simply point to our server
  • www.twyle.xyz will also point to the production server, but at the moment it will just be a CNAME that points to our elastic IP.

Click on the Create record button:

Select Simple routing then click Next:

Select the Define simple record button:

Under the Record name, enter dev and for the Record type choose A Routes traffic to an IPV4 address and some AWS resources:

For the Value/Route traffic to select IP address or another value, depending on the record type. For the IP address, log into your AWS account in another tab, then in the instances tab, select the EC2 server that we just created the elastic IP address for. Under the details tab, scroll down to the elastic IP section as we did before, then copy the value and paste it into the IP address field. Then click on Define simple record button (leave other values as default):

You should get the following:

Once again click on the Define simple record button, this time to create a CNAME record for stage.twyle.xyz , then fill it as follows:

  • Under Record name use stage.
  • For the Record type use CNAME — Route traffic to another domain name and to some AWS resources.
  • For the Value/Route traffic to use IP address or another value, depending on the record type
  • Then enter the elastic IP address in the IP address field
  • Then press the Define simple record button.
  • Follow the same steps for the prod.twyle.xyz and www.twyle.xyz only replacing the values for the Record name field.

Once done, you will have the following:

Click on the Create records button. And with that, we have created a hosted zone on AWS.

Step 4: Point Namecheap Servers to AWS Servers

We will now update the Namecheap DNS servers for our domain to point to the AWS servers that Route 53 gave us:

Sign into your Namecheap account. Select the domain that you want to manage:

Scroll down to the NAMESERVERS section, then from the drop-down select Custom DNS and enter the four addresses given to you by route 53:

Make sure to delete the periods after the server names then click on the blue tick:

Give it one to two hours and the domain name should now point to your server IP address. In our case, this will point to a nginx server that acts as a proxy to a flask server running on the EC2 instance. You can check out the tutorial on How to Deploy a Production Grade Flask application to an AWS EC2 Instance using GitHub Actions, where we use this domain name.

Conclusion

In this tutorial we:

  • Purchased a domain on Namecheap.
  • Created an elastic IP address for an EC2 server instance using the AWS Elastic IP service.
  • Created a hosted zone on AWS using route 53 and the elastic IP address created earlier on.
  • Associated the domain purchased on Namecheap with the elastic IP address using the hosted zone
  • Pointed the Namecheap domain servers to the AWS servers.

That’s it for this article. I hope you enjoyed it and learnt something. Give it a clap or share it out and do not hesitate to reach out to me in-case of an issue. This is part of a tutorial series on How to Deploy a Production Grade Flask application to an AWS EC2 Instance using GitHub Actions. I am Lyle, a junior software engineer with a passion for developing, testing and deploying scalable services. You can find me on twitter, linkedin, github and here’s my portfolio. See you next time.

--

--

Lyle Okoth

Conversational AI Engineer | Building conversational AI agents that work with humans to automate various workflows.