Skip to content

Instantly share code, notes, and snippets.

@unacceptable
Last active September 6, 2017 14:20
Show Gist options
  • Save unacceptable/afd6b16caaa814ac0c3c364d7742c064 to your computer and use it in GitHub Desktop.
Save unacceptable/afd6b16caaa814ac0c3c364d7742c064 to your computer and use it in GitHub Desktop.
This is a quick and dirty to scan the EC2 and RDS instances on an account, and by no means is using best practices for parsing json.
while read -r region; do
printf "%s:\n" "$region";
aws ec2 describe-instances --region "$region" | \
awk -F '"' '/InstanceType/ {print $4}' | \
sort | \
uniq -c;
aws rds describe-db-instances --region "$region" | \
awk -F '"' '/DBInstanceClass/ {print $4}' | \
sort | \
uniq -c;
done < <( echo 'ap-northeast-1
ap-northeast-2
ap-south-1
ap-southeast-1
ap-southeast-2
ca-central-1
eu-central-1
eu-west-1
eu-west-2
sa-east-1
us-east-1
us-east-2
us-west-1
us-west-2')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment