Skip to content

Instantly share code, notes, and snippets.

@aerostitch
Last active June 10, 2022 22:14
Show Gist options
  • Save aerostitch/d72d6f159f099f9338cd7a2da6246cdf to your computer and use it in GitHub Desktop.
Save aerostitch/d72d6f159f099f9338cd7a2da6246cdf to your computer and use it in GitHub Desktop.
Lists all the ELB names and the number of instances attached to them
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].{name:LoadBalancerName,instances:Instances[*].InstanceId}' | jq '[.[] | {name: .name, inst: .instances | length}]'
# List only the empty ones:
aws elb describe-load-balancers --query 'LoadBalancerDescriptions[*].{name:LoadBalancerName,instances:Instances[*].InstanceId}' | jq '[.[] | if (.instances | length) <= 0 then {name: .name, number_of_instances: .instances | length} else empty end]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment