Ebook 'From FinOps to proven cloud cost management & optimization strategies'
Whitepaper 'FinOps and cost management for Kubernetes'

How to release Elastic IPs on Amazon EC2

Share on linkedin
Share on twitter
Share on facebook

Problem statement: Elastic IPs are free of charge only in certain cases

Let’s begin this article by identifying two types of IP addresses that can be assigned to Amazon EC2 instances – private and public addresses. Private IP addresses are responsible for the communication between internal AWS services and resources in a single VPC, whereas public IP addresses can be additionally attached to instances in order to establish external connections, and enable Internet communication. These public IPv4 IP addresses are called Elastic IP addresses (EIP). The huge advantage of using this type of IP address lies in a simple remapping of this IP to a different machine if that is indeed required. From an outsider’s point of view, there will be no difference for the end-users, they will still use the existing public IP.

To assign an EIP to an AWS instance, you need to allocate it first. In general, Elastic IP addresses are free of charge, but only when the following rules are applied:

  • EIP is assigned to an EC2 instance
  • The instance is running
  • The instance has only one EIP attached
  • EIP remapping is limited to 100 times per month

However, if the Elastic IP doesn’t meet one of the rules mentioned above, you will be charged at the following rates:

  • $0.005 per additional Elastic IP address associated with a running instance, per hour, on a pro rata basis
  • $0.005 per Elastic IP address not associated with a running instance, per hour, on a pro rata basis
  • $0.10 per Elastic IP address remap for additional remaps, over 100 per month

Keeping an eye on all active cloud resources is not an easy task, therefore, in order to get your resources organized and manageable, we highly recommend tagging them. Discover the rules, appropriate to your team, and tag all the resources, including EIP addresses to minimize the risk of losing them.

OptScale, a FinOps and cloud cost management platform, is available on cloud marketplaces

AWS-logo
azure
Alibaba Cloud marketplace
Digital-ocean

How to release EIPs

Before releasing an elastic IP, select that this address is not associated with any AWS resources; such as an EC2 instance, NAT gateway, or Network Load Balancer; otherwise, you will not be able to release it.

From AWS console:

Go to the EC2 service and click on Elastic IPs in the left menu to observe the addresses of the specific region. 

To release the IP, simply select it in the list, click on Actions → Release Elastic IP addresses, as below:

Elastic IP addresses Amazon EC2

From AWS CLI:

A programmatic way to operate the resources delivers much broader capabilities, therefore, you have a choice whether you want to release a specific IP or find all unused IPs and remove them at once.

Depending on the AWS EC2 platform that you use to launch the instances, select an appropriate command to find and release EIP in all regions:

EC2-Classic

aws ec2 describe-addresses --query 'Addresses[].[PublicIp,AssociationId]' --output text | \ awk '$2 == "None" { print $1 }' | \ xargs -I {} aws ec2 release-address --public-ip {}

EC2-VPC

aws ec2 describe-addresses --query 'Addresses[].[AllocationId,AssociationId]' --output text | \ awk '$2 == "None" { print $1 }' | \ xargs -I {} aws ec2 release-address --allocation-id {}

Note:
If you use EC2-Classic, you can use the aws ec2 release-address --public-ip command to release a specific elastic IP, otherwise you must use aws ec2 release-address --allocation-id eipalloc-76f5890b

Find our recent article ‘How to tag resources in the AWS Management Console’ here → https://hystax.com/how-to-tag-resources-in-the-aws-management-console

Enter your email to be notified about new and relevant content.

Thank you for joining us!

We hope you'll find it usefull

You can unsubscribe from these communications at any time. Privacy Policy

News & Reports

FinOps & Test Environment Management

A full description of OptScale as a FinOps and Test Environment Management platform to organize shared IT environment usage, optimize & forecast Kubernetes and cloud costs

From FinOps to proven cloud cost management & optimization strategies

This ebook covers the implementation of basic FinOps principles to shed light on alternative ways of conducting cloud cost optimization

Engage your engineers in FinOps and cloud cost saving

Discover how OptScale helps companies quickly increase FinOps adoption by engaging engineers in FinOps enablement and cloud cost savings