Skip to content

Instantly share code, notes, and snippets.

@anamorph
Created January 8, 2024 08:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anamorph/a5c83fe6aff5d1a7153801b7458ab35f to your computer and use it in GitHub Desktop.
Save anamorph/a5c83fe6aff5d1a7153801b7458ab35f to your computer and use it in GitHub Desktop.
[aws] List all the Unattached Elastic IP addresses in all of the Opted-In Regions
#!/bin/sh
# id: check_unattached_EIPs.sh
# author: nicolas david - nicolas@openlab.fr
#
## version history:
# ----------------------------------------------------------------------------
# v1.0 nicolas@ Initial Version
#
# ----------------------------------------------------------------------------
for i in $(aws ec2 describe-regions --all-regions | jq -r '.Regions | .[] | .RegionName + " " + .OptInStatus' | grep -v not-opted-in | cut -d' ' -f1)
do
aws ec2 describe-addresses --query "Addresses[?NetworkInterfaceId == null ].PublicIp" --region $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment