-
-
Save kshailen/430047859409ae92b6f9680cf1569e5b to your computer and use it in GitHub Desktop.
List all EC2 instances
This file contains hidden or 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 hidden or 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