DEV Community

Krembo Vitman
Krembo Vitman

Posted on

How to Find Unused Elastic IPs in AWS

Unused Elastic IPs are one of the easiest AWS cost leaks to miss. They look
small, but they keep billing while they are allocated and not attached to a
running resource.

This guide shows how to find them safely.

What Is an Unused Elastic IP?

An Elastic IP is likely unused when it has no AssociationId.

That means AWS has allocated the public IP to your account, but it is not
currently associated with an EC2 instance, NAT gateway, network interface, or
other resource.

AWS CLI Command

Run this for one region:

aws ec2 describe-addresses \
  --region us-east-1 \
  --query 'Addresses[?AssociationId==null].[AllocationId,PublicIp]' \
  --output table
Enter fullscreen mode Exit fullscreen mode

Run it with a profile:

aws ec2 describe-addresses \
  --profile production \
  --region us-east-1 \
  --query 'Addresses[?AssociationId==null].[AllocationId,PublicIp]' \
  --output table
Enter fullscreen mode Exit fullscreen mode

Check All Regions

Elastic IPs are regional, so check every enabled region:

for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text); do
  echo "Region: $region"
  aws ec2 describe-addresses \
    --region "$region" \
    --query 'Addresses[?AssociationId==null].[AllocationId,PublicIp]' \
    --output table
done
Enter fullscreen mode Exit fullscreen mode

Before You Release an Elastic IP

Do not release an IP just because it is unattached.

First check:

  • DNS records
  • customer allowlists
  • partner allowlists
  • firewall rules
  • webhook documentation
  • old deployment or rollback notes

Some public IPs are referenced outside AWS, so AWS cannot tell you every
dependency.

Easier Option

AWS Waste Finder scans for unassociated Elastic IPs and includes them in a
Markdown, JSON, or HTML report.

Free repo:
https://github.com/byanivb/aws-waste-finder

Paid starter bundle:
https://basilian1.gumroad.com/l/aws-waste-finder

Top comments (0)