Skip to content

Instantly share code, notes, and snippets.

@sodejm
Created September 7, 2018 19:53
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 sodejm/195bbaf1d13ca4fb1cd5541ba1b87032 to your computer and use it in GitHub Desktop.
Save sodejm/195bbaf1d13ca4fb1cd5541ba1b87032 to your computer and use it in GitHub Desktop.
# Author: sodejm
# Add to bash_profile as a quick way to list your US EC2 instances
# requires the aws-cli
# use: listusec2
# List all EC2 Instances for US regions
function listec2(){
for region in `aws ec2 describe-regions --filters "Name=endpoint,Values=*us*" --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