Tech Junkie Blog - Real World Tutorials, Happy Coding!: Iaas With AWS: Create An Elastic IP And Assign It To An Instance

Monday, October 12, 2020

Iaas With AWS: Create An Elastic IP And Assign It To An Instance

 When an instance is created in AWS a public and private IP is assigned to the instance.  The private IP does not change, but the public IP address changes each time the instance reboot or is stopped.  On reboot you might be lucky enough to grab the same public IP, but it's not guaranteed.  But on stoppage you will definitely be assigned a new public IP.

That's probably not a good thing a real world situation, that's where an Elastic IP comes into play.  An Elastic IP is a static IP that when assigned does not change.  However, there's no free lunch so you will be charged for it.  So only create one if you really need it.  I would recommend that you use the public DNS instead when you are not in production.  Say the development and test environment.  You might want to spend some money on the staging environment to mirror production as close as possible.

In the following section I will show you how to create an Elastic IP and assign it to an instance.  You probably want to delete it after you create it if you do not want to pay.  Only keep it if you want to use it.

So to create an Elastic IP, click on the "Elastic IPs" link under "Network & Security" section in the instances page








Click on "Allocate Elastic IP address"


Accept the default and click on "Allocate"


You will see that a new Elastic IP has been allocated to you


Even though an Elastic IP has been allocated, it still has not been associated with any resources, the next thing we want to do is associate it with our Linux instance.  To do that click on the "Actions" dropdown and select "Associate Elastic IP address"
Under "Resource type" select "Instance", then fill in the Instance id and the private IP address.  Those should be dropdowns.  Then click "Associate"


If you go back to the instance "Description" tab you should see that the Elastic IP has been associated with the instance, and it has replaced the dynamic public IP that was assigned by default.  It would not change on restart or stoppage from now on.

No comments:

Post a Comment

Search This Blog