How to find all unused IP address in Amazon Web Services

This is a common task for a System Admin and sometimes it requires automation. Not all System Admins will have all the nice tools to administer their Amazon Web Services resources so we have to come up with poor mans monitoring and scripting. Having a bunch of people doing development in AWS is such a nice way to work but this developers leave a lot of garbage behind and in this post we will see How to find and release unused IP address in Amazon Web Services.

  • You can do it Region by Region using the AWS Console as seen bellow:
  • Or you can do it using the aws client and some nifty shell scripting skills.
See the loop example code here and see it in action bellow:
for region in aws ec2 describe-regions --output text | cut -f3
do
     echo -e "\nListing IPs in region '$region':"
     aws ec2 describe-addresses --region $region
done