Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save florin-andrei-curbside/936092f95525199b0437eaaecbc77644 to your computer and use it in GitHub Desktop.
Save florin-andrei-curbside/936092f95525199b0437eaaecbc77644 to your computer and use it in GitHub Desktop.
list all EC2 instances in all regions
#!/usr/bin/env bash
for reg in `aws ec2 describe-regions --query 'Regions[].[RegionName]' --output=text`; do
aws ec2 describe-instances --region ${reg} \
--query 'Reservations[].Instances[].[Tags[?Key==`Name`] | [0].Value, InstanceId, Placement.AvailabilityZone, PrivateIpAddress, PublicIpAddress]' --output=text
done
# the output is Google Docs spreadsheet friendly.
# To make it human friendly, change it to --output=table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment