Skip to content

Instantly share code, notes, and snippets.

@tfentonz
Created September 2, 2021 03:30
Show Gist options
  • Save tfentonz/085efab1b9a54bb33e6adf8ba7a65bab to your computer and use it in GitHub Desktop.
Save tfentonz/085efab1b9a54bb33e6adf8ba7a65bab to your computer and use it in GitHub Desktop.
AWS CLI script to list all Application Load Balancer listeners with an SSL policy
#!/bin/bash
# List application load balancers by ARN
load_balancer_arns=$(aws elbv2 describe-load-balancers \
--query 'sort_by(LoadBalancers[?contains(LoadBalancerArn,`:loadbalancer/app/`)],&LoadBalancerArn)[].[LoadBalancerArn]' \
--output text)
# For each ALB describe listeners with an SSL policy
for arn in $load_balancer_arns
do
aws elbv2 describe-listeners \
--load-balancer-arn "$arn" \
--query 'Listeners[?SslPolicy!=`null`].{LoadBalancerArn:LoadBalancerArn,ListenerArn:ListenerArn,Protocol:Protocol,Port:Port,SslPolicy:SslPolicy}' \
--output text
done
exit 0
@vgwshouse
Copy link

Saved me writing it myself. Thank you for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment