Skip to content

Instantly share code, notes, and snippets.

@dstokes
Created June 12, 2017 23:13
Show Gist options
  • Save dstokes/b697c4057c4d7ec910dff3bfa5f2506b to your computer and use it in GitHub Desktop.
Save dstokes/b697c4057c4d7ec910dff3bfa5f2506b to your computer and use it in GitHub Desktop.
Print SSL certificate names associated with ELB & ALB
#!/bin/bash
# setup ssl certificate formatter
exec 3> >(awk '$2 != "None" {split($2, a, "/"); $2=a[length(a)]; print; system("")}')
# inspect nlb
aws elb describe-load-balancers \
--query 'LoadBalancerDescriptions[].{Name: LoadBalancerName, SSLCertificate: ListenerDescriptions[?Listener.Protocol==`HTTPS`].Listener.SSLCertificateId | [0]}' \
--output text >&3
# inspect alb
ALBS=$(aws elbv2 describe-load-balancers \
--query 'LoadBalancers[].{Name: LoadBalancerName, Z: LoadBalancerArn}' \
--output text)
while IFS=$'\t' read name listener; do
echo -e "$name\t$(aws elbv2 describe-listeners --load-balancer-arn $listener --query 'Listeners[?Protocol==`HTTPS`].Certificates[0].CertificateArn' --output text)" >&3
done <<<"$ALBS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment