How to assign an Elastic IP to your EC2 Instance in AWS and Why do you need it?
In this article, I will show you how to assign an elastic IP to your EC2 Instance in AWS and why do you need it?
Usually, when you create an EC2 instance in AWS it assigns a private and a public IP to your Instance, however, in this case, even the Public IP is not Static, it changes when your Instance is restarted.
Therefore, any Instance hosting your website or an app (in a Production environment.) should have an Elastic IP assigned which is just a static Public IP.
How to assign an elastic IP to your EC2 Instance in AWS?
Browse: https://aws.amazon.com/ and click on “Sign in to the Console” button on top right. (see image below):
In your AWS Console dashboard click on “EC2” link to find your Instance on which you will have to assign an elastic IP (In-short Static Public IP) (see image below):
Click on “Running Instances” under “Resources” (see image below):
Now, highlight the instance for which you would like to assign elastic IP, click on Actions tab on top, go to Networking and then click on “Manage IP Addresses” (see image below)
“Manage IP Addresses” window will pop-up, click on “Allocate an elastic IP” link then to continue to assign one for this EC2 Instance. (see image below)
As soon as you hit “Allocate an elastic IP” it will open a new tab with the following information:
(see image below):
Hit Allocate to get a static public IP assigned to your EC2 Instance and once done it will show you the following message. (see image below):
OR (You can also Allocate new address from this method)
NOTE: It will not assign the IP to your Instance automatically, therefore we need to click on close button and it will take you to Elastic’s IP page:
Highlight your IP and click on “Actions” tab, from the drop-down click on “Associate Address” (see image below):
A new page will open in which you will have to select the Instance and Private IP then hit Associate. (see image below):
As soon as it’s associated you will see this message:
Hit the close button and now we are left with configuring ‘A’ record in DNS.
In this case, since we have purchased our domain from AWS via Route53, we must go in there to change the DNS record.
However, in your case, you will have to find the place where your DNS is, for e.g.: GoDaddy, Network Solutions etc.
Go back and click on “Services” on top left and then scroll down to “Networking & Content Delivery” then hit “Route 53”
You will see a new window with “DNS Management” (see image below):
Click on “Hosted Zones” and click on your respective domain for which you wish to add the ‘A’ record with new public IP: (see image below):
Click on “Create Record Set” and type “www” in the name field and your public IP in the “Value field” leave rest of the data to defaults unless you want to change it and click on “Create”
DNS Records would be updated in few minutes. (see image below):