Skip to content

Instantly share code, notes, and snippets.

@nshenry03
Created May 31, 2016 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nshenry03/ccdc551945c16ad131582604fab8c604 to your computer and use it in GitHub Desktop.
Save nshenry03/ccdc551945c16ad131582604fab8c604 to your computer and use it in GitHub Desktop.
Find instances that are out of service for each load balancer in an Amazon account
AWS_CONFIG_PROFILE='prod' # from ${HOME}/.aws-config
for elb in $(
aws elb describe-load-balancers --profile "${AWS_CONFIG_PROFILE}" | \
jq '.LoadBalancerDescriptions | .[] | .LoadBalancerName' | \
sed 's/"//g'
) ; do
echo -e "ELB: ${elb}\n========================================"
aws elb describe-instance-health \
--load-balancer-name ${elb} --profile "${AWS_CONFIG_PROFILE}" | \
jq '.InstanceStates | .[] | select(.State!="InService") | .InstanceId'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment