One-Liners - Get AWS AZ Counts

OK, so not truly a one-liner, but a nice quick-n-dirty way to get a count of all active AZs for each region for your AWS account.

echo -e "$(tput bold)Region          | # AZs$(tput sgr0)"
for region in $(aws ec2 describe-regions | jq -r '.Regions[].RegionName'); do
    num_azs=$(aws ec2 describe-availability-zones --region ${region} | jq -r '.AvailabilityZones | length')
    printf '%-15s | %5s\n' ${region} ${num_azs}

This requires jq and the AWS CLI to be installed.

comments powered by Disqus