How to release(delete) Elastic IP from AWS?

I thought of writing this blog because I have a personal AWS account which I generally use for learning purposes but a couple of months ago assigned the Elastic IP address to one of my experimental EC2 accounts and forgot about deleting the EC2 instance as well as releasing(deleting) Elastic IP addressfor about a month.

Although I have used t2.micro EC2 instance but still, I have to pay for the price of Elastic IP which I was using along with other resources. Here is the cost graph which was constant for the month of November (purple line) -

Cost graph of my Elastic IP address usages

Table of Content

  1. Why do you want to release(delete) Elastic IP?
  2. Why Elastic IP address is important?
  3. Release(Delete) Elastic IP address from AWS Console?
  4. How to Release(Delete) an Elastic IP address when 'Associate address, Release address, and Disassociate address' are greyed(disabled) ?
  5. Release Elastic IP address using AWS CLI(Command Line Interface)
  6. Conclusion

1. Why do you want to release(delete) Elastic IP?

1. Cost - To avoid being charged for Elastic IP addresses that are not in use. AWS charges for Elastic IP addresses that are not associated with a running instance. If you have Elastic IP addresses that are not being used, you can release them to avoid being charged for their use.

2.AWS puts a limit on the number of Elastic IP - To free up Elastic IP addresses for use with other instances. AWS limits the number of Elastic IP addresses that you can associate with your account. If you have reached this limit and need to associate additional Elastic IP addresses with your instances, you will need to release some of your existing Elastic IP addresses first.

3. To make a change in Network Interface - To make changes to the network configuration of your instances. In some cases, you may need to release an Elastic IP address and then re-associate it with the same or a different instance in order to make changes to the network configuration of your instances. For example, if you want to change the security groups associated with an instance, you may need to release and re-associate its Elastic IP address in order to apply the changes.


2. Why Elastic IP address is important?

But let's talk about a few points on Why Elastic IP is important? - Elastic IP addresses are important in Amazon Web Services (AWS) because they provide a static and stable IP address that can be associated with a specific AWS instance. This is useful for a number of reasons, including the following:

  1. Have a Static IP - Elastic IP addresses allow you to remap your static IPv4 address to a new instance in the event that your current instance fails or is terminated. This ensures that your applications and services remain available, even if the underlying instance experiences an outage or is taken down for maintenance.

  2. Consistent Network - Elastic IP addresses enable you to maintain consistent network access to your resources. This is important for applications that require a fixed IP address, such as VPNs or remote desktop connections.


3. Release(Delete) Elastic IP address from AWS Console?

Follow the steps mentioned below for releasing the Elastic IP address -

  1. Got EC2 Dashboard and in the left navigational panel you will find Network & Security -> Elastic IPs

Goto Network security and click on Elastic IPs

  1. In the Elastic IP address section you will find all the Elastic IPs allocated under your AWS account.

List of Elastic IP address

  1. Release Elastic IP address by selecting them individually and then click on Actions and you will find an option for Release Elastic IP addresses
    List of Elastic IP address

Note- In case if you find the Release Elastic IP addresses button disabled, please refer to next section to find and delete the NAT Gateway before releasing Elastic IP address.


4. How to Release(Delete) an Elastic IP address when 'Associate address, Release address, and Disassociate address' are greyed(disabled) ?

In some cases also it possible that Release Elastic IP address, Disassociate Elastic IP address is disabled. In such cases, you need to look for NAT Gateway associated with the Elastic IP.

Can not release Elastic IP because Release Elastic IP Address, Disassociate IP address buttons are grayed out

First, you have to delete the NAT Gateway and after that, you can relase Elastic IP.Here are the steps which you need to follow -

  1. Click on the details of Elastic IP address then goto NAT Gateway ID to view more details

NAT Gateway details

  1. After that you need to click on Actions -> Delete NAT gateway. After selecting the Delete it will reconfirm from you by manually typing Delete. It might take a few minutes to delete the NAT Gateway

Cick on Delete NAT gateway

  1. After deleting the NAT Gateway, you can see that the Release Elastic IP address button is enabled and you can release the Elastic IP.

Relase Elastic IP address button is Enabled


5. Release Elastic IP address using AWS CLI(Command Line Interface)

  1. Releasing the Elastic IP address using AWS CLI is very simple, just follow the command below -

    1# Replace the Elastic IP address in the command 
    2# After the successful release of the Elastic IP address no output will be returned 
    3
    4aws ec2 release-address --public-ip 198.51.100.0
    
1
22. Releasing the Elastic IP address for EC2-VPC
3
4 ```bash
5 # Replace the allocation-id in the following command 
6
7 aws ec2 release-address --allocation-id eipalloc-4594750g

6. Conclusion

Elastic IP addresses in AWS serve the important purpose of allowing users to easily associate a static IP address with their EC2 instances. The process for releasing an Elastic IP address is simple and can be performed through the AWS Management Console as well as AWS CLI.

Releasing an Elastic IP address has the potential benefit of optimizing the performance and cost-efficiency of your AWS environment, as it allows you to reclaim unused IP addresses and prevent them from accruing unnecessary charges. I recommend that users carefully consider their need for Elastic IP addresses and release any unused addresses to optimize their AWS environment.

Posts in this Series