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) -
Table of Content
- Why do you want to release(delete) Elastic IP?
- Why Elastic IP address is important?
- Release(Delete) Elastic IP address from AWS Console?
- How to Release(Delete) an Elastic IP address when 'Associate address, Release address, and Disassociate address' are greyed(disabled) ?
- Release Elastic IP address using AWS CLI(Command Line Interface)
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:
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.
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 -
- Got EC2 Dashboard and in the left navigational panel you will find Network & Security -> Elastic IPs
- In the Elastic IP address section you will find all the Elastic IPs allocated under your AWS account.
- Release Elastic IP address by selecting them individually and then click on Actions and you will find an option for Release Elastic IP addresses
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.
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 -
- Click on the details of Elastic IP address then goto NAT Gateway ID to view more details
- 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
- After deleting the NAT Gateway, you can see that the Release Elastic IP address button is enabled and you can release the Elastic IP.
5. Release Elastic IP address using AWS CLI(Command Line Interface)
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
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.