Skip to content

Instantly share code, notes, and snippets.

@khous
Created June 18, 2018 17:54
Show Gist options
  • Save khous/3be993c2a8cbf767d28c4def21c7f2aa to your computer and use it in GitHub Desktop.
Save khous/3be993c2a8cbf767d28c4def21c7f2aa to your computer and use it in GitHub Desktop.
Enumerate public AMIs per region
#!/usr/bin/env bash
echo "Searching for image where name begins with $1"
regions=$(aws ec2 describe-regions --output text --query 'Regions[*].RegionName')
for region in $regions; do
(
echo "$region $( aws ec2 describe-images --region $region --filters Name=is-public,Values=true Name=name,Values="$1*" | grep ImageId )"
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment