Skip to content

Instantly share code, notes, and snippets.

@sudheerchamarthi
Last active November 10, 2020 15:13
Show Gist options
  • Save sudheerchamarthi/e1adb1ecf43a155a31cdda5424d83939 to your computer and use it in GitHub Desktop.
Save sudheerchamarthi/e1adb1ecf43a155a31cdda5424d83939 to your computer and use it in GitHub Desktop.
import boto3
client = boto3.client('elbv2',region_name='us-east-1')
elb = client.describe_load_balancers()
for lb in range(len(elb['LoadBalancers'])):
ALBName = elb['LoadBalancers'][lb]['LoadBalancerName']
ALBArn = elb['LoadBalancers'][lb]['LoadBalancerArn']
if elb['LoadBalancers'][lb]['Type'] == "application":
elblistener = client.describe_listeners(LoadBalancerArn=elb['LoadBalancers'][lb]['LoadBalancerArn'])
try:
SSLPolicy = elblistener['Listeners'][0]['SslPolicy']
except:
if len(elblistener['Listeners']) > 1:
SSLPolicy = elblistener['Listeners'][1]['SslPolicy']
else:
SSLPolicy = 'NA'
tags = client.describe_tags(ResourceArns=[ALBArn])
try:
for tag in range(len(tags['TagDescriptions'][0]['Tags'])):
if tags['TagDescriptions'][0]['Tags'][tag]['Key'] == "System":
systag = tags['TagDescriptions'][0]['Tags'][tag]['Value']
elif tags['TagDescriptions'][0]['Tags'][tag]['Key'] == "SubSystem":
subsystag = tags['TagDescriptions'][0]['Tags'][tag]['Value']
elif tags['TagDescriptions'][0]['Tags'][tag]['Key'] == "Environment":
env = tags['TagDescriptions'][0]['Tags'][tag]['Value']
except:
systag='None'
subsystag='None'
env = 'None'
print(ALBName + " ," + SSLPolicy + ", " + systag + " ," + subsystag + "," + env)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment