Attach Elastic IP To EC2 Instance

When you launch an EC2 instance in a public subnet , The EC2 instance will have a public IP but this IP Address is not static Because If you restart or stop and start the EC2 instance will change.

If you have configured a domain in this server and if you perform any activity , the IP address will change then you have to change this IP address in DNS and other places wherever applicable.

To overcome this issue , We have to create a elastic ip address and attach it to the instance.

In this article , We are going to learn how to create a elastic IP address and attach elastic ip to the EC2 instance.

If you don’t have an EC2 instance , To create one Refer this article

What Is Elastic IP Address?

Elastic IP Address is a static public ipv4 IP address.

You can attach the Elastic IP Address to any network interface or any instance in your VPC.

Understanding Elastic IP Address

  • First We need to allocate an elastic ip address in your VPC.
  • Then we can associate it with the EC2 instance.
  • Elastic IP address can be moved from one EC2 instance to another.
  • You will be charged if the Elastic Ip address is not associated with any ec2 instance.
  • The elastic ip address remains in your VPC unless you manually release them.

Creating Elastic IP Address

To create a Elastic IP Address , Open the Amazon VPC CONSOLE

In the left navigation pane , Select Elastic IPs

you will see the following page,

Choose Allocate new address , We are going to create elastic ip address from the Amazon’s pool of IP addresses. Choose Amazon pool.

If you have your own pool of IP addresses , Choose Owned by me.

Click Allocate.

we have created a elastic ip address.

You can see the lists of Elastic IP Address , By choosing Elastic IPs in the Navigation pane.

Associate Elastic IP To EC2 Instance

To attach the newly created elastic ip address with ec2 instance , Open VPC CONSOLE

In the navigation pane , Choose Elastic IPs , Choose the elastic ip which you want to be attached with ec2 instance.

Under Actions , select Associate address

In this page , Select the Resource Type as Instance ,

Under Instance , select the EC2 instance and choose the Private IP of that EC2 instance.

Then Click Associate.

To verify , Go to EC2 CONSOLE , Choose Instances in the Navigation pane

Select the EC2 instance , Under Description , You should see the Elastic IPs , the IP of the elastic ip address which you have created.

To Remove Elastic IP From Instance

If you want to remove the elastic ip address from EC2 instance or If you want to use the same elastic ip to other EC2 instance.

First We have to disassociate the elastic ip address from the EC2 instance.

For that . Open the VPC CONSOLE , Choose Elastic IPs

Select the Elastic IP address , Under Actions , Choose Disassociate address

Now that the elastic ip address is removed from your EC2 instance.

To Delete Elastic IP Address

If you wish to delete the Elastic IP Address itself,

Open the VPC CONSOLE , Choose Elastic IPs

Select the Elastic IP Address , Under Actions , select Release addresses

It will ask you for an Acknowledgement , Select Release.

We have learnt how to create an elastic ip address , associate it with ec2 instance , disassociate from ec2 instance and release elastic ip address.

Thanks for reading this article.

Please do check out my other publications.