Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boto3 does not list my Application Load Balancer

I am new to boto3 and am using it for automating the process of register and deregister EC2 instances from load balancers.

This is my sample Python code:

import boto3
elbList = boto3.client('elb')
bals = elbList.describe_load_balancers()
for elb in bals['LoadBalancerDescriptions']:
    print 'ELB Name:' + elb['LoadBalancerName'] +  'ELB scheme type: ' + elb['Scheme']

This script only lists all my classic load balancers but my application load balancers are not listed.

How do I list my application load balancer and list all the instances attached to it?

like image 552
Gaurav Parashar Avatar asked Dec 18 '22 06:12

Gaurav Parashar


1 Answers

Strangely enough, Application Load Balancers are only visible via the v2 interface:

client = boto3.client('elbv2')
response = client.describe_load_balancers()

See: boto3 ElasticLoadBalancingv2 documentation

like image 144
John Rotenstein Avatar answered Jan 13 '23 11:01

John Rotenstein