Skip to content

Instantly share code, notes, and snippets.

@sredhar
Created October 23, 2013 20:20
Show Gist options
  • Save sredhar/7125981 to your computer and use it in GitHub Desktop.
Save sredhar/7125981 to your computer and use it in GitHub Desktop.
Release unused elastic IPs
import boto
import boto.ec2
conn = boto.connect_ec2()
eips = conn.get_all_addresses()
for eip in eips:
if eip.association_id is None:
try:
conn.release_address(public_ip=eip.public_ip)
except boto.exception.EC2ResponseError:
conn.release_address(allocation_id=eip.allocation_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment