Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Created September 25, 2018 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffbrl/4dfe2e809a40864e807173b2063d141e to your computer and use it in GitHub Desktop.
Save jeffbrl/4dfe2e809a40864e807173b2063d141e to your computer and use it in GitHub Desktop.
List AWS EC2 instances in all regions
#!/bin/sh
# From fitblip at https://github.com/aws/aws-cli/issues/1777#issuecomment-284262414
for region in `aws ec2 describe-regions --output text | cut -f3`
do
echo -e "\nListing Instances in region:'$region'..."
aws ec2 describe-instances --region $region | jq '.Reservations[] | ( .Instances[] | {state: .State.Name, name: .KeyName, type: .InstanceType, key: .KeyName})'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment