Last active
April 17, 2020 01:10
-
-
Save fboaventura/e76f2f751604d8a895259899d06b98f8 to your computer and use it in GitHub Desktop.
List all EC2 instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Prereqs: | |
# Ubuntu 16.04+: apt install awscli jq | |
# Centos 7+ : yum install awscli jq | |
set +m | |
for region in $(aws ec2 describe-regions --query "Regions[*].[RegionName]" --output text); do | |
aws ec2 describe-instances --region "$region" | jq ".Reservations[].Instances[] | {type: .InstanceType, state: .State.Name, tags: .Tags, zone: .Placement.AvailabilityZone}" & | |
done; wait; set -m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cayenne :: ~/bin » set +m | |
for region in $(aws ec2 describe-regions --query "Regions[*].[RegionName]" --output text); do | |
aws ec2 describe-instances --region "$region" | jq ".Reservations[].Instances[] | {type: .InstanceType, state: .State.Name, tags: .Tags, zone: .Placement.AvailabilityZone}" & | |
done; wait; set -m | |
{ | |
"type": "t2.micro", | |
"state": "pending", | |
"tags": null, | |
"zone": "us-east-1e" | |
} | |
cayenne :: ~/bin » set +m | |
for region in $(aws ec2 describe-regions --query "Regions[*].[RegionName]" --output text); do | |
aws ec2 describe-instances --region "$region" | jq ".Reservations[].Instances[] | {type: .InstanceType, state: .State.Name, tags: .Tags, zone: .Placement.AvailabilityZone}" & | |
done; wait; set -m | |
{ | |
"type": "t2.micro", | |
"state": "terminated", | |
"tags": null, | |
"zone": "us-east-1e" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment