Created
June 18, 2021 16:47
-
-
Save andreyev/e2590962f2fbebcdcaf8626f34ce2efb to your computer and use it in GitHub Desktop.
compare and instances reservations on every region of aws
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
aws ec2 describe-regions --region us-east-1 | jq -r '.Regions[].RegionName' | sort | while read REGION; do aws --region $REGION ec2 describe-instances | jq -r '.Reservations[].Instances[]|select(.State.Name|match("running"))|"\(.InstanceType)"'| sort | uniq -c > /tmp/instances; aws --region $REGION ec2 describe-reserved-instances | jq -r '.ReservedInstances[]|select(.State|match("active"))|" \(.InstanceCount) \(.InstanceType)"'| sort > /tmp/reservations; [[ -s /tmp/instances || -s /tmp/reservations ]] && echo -ne "Region: $REGION\n-Instances:\n$(cat /tmp/instances)\n-Reservations:\n$(cat /tmp/reservations)\n"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment