Skip to content

Instantly share code, notes, and snippets.

@garyellis
Created March 13, 2018 15:36
Show Gist options
  • Save garyellis/f9c3e5333d14df268f0225caed567bde to your computer and use it in GitHub Desktop.
Save garyellis/f9c3e5333d14df268f0225caed567bde to your computer and use it in GitHub Desktop.
#!/bin/bash
function get_classic_elb_backend_counts(){
region=${2:-us-west-2}
aws --profile $1 --region $region elb describe-load-balancers | \
jq -r --arg profile "$1" --arg region "$region" '.LoadBalancerDescriptions[] | [$profile, $region, .LoadBalancerName, (.Instances|length)] | @csv'
}
function aws_regions(){
aws ec2 describe-regions | jq -r '.Regions[].RegionName'
}
function get_classic_elb_backend_counts_all_regions() {
for region in $(aws_regions); do
get_classic_elb_backend_counts $1 $region
done
}
get_classic_elb_backend_counts_all_regions $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment