amazon web services - How to query AWS to get ELB names and attached instances to that using python boto modules? -


i trying retrieve elb names , attached instances ids using python boto modules.

{     import boto      conn = boto.connect_elb()     conn.get_all_load_balancers() } 

gives load-balancer names how can retrieve instance-ids attached load-balancer ?

conn.get_all_load_balancers() - returns list of elbs objects. each elb object has parameter instances show attached instances. , there can id's.
if want find elb name, need filter first loop.

so should work (thanks @frédéric henri update):

import boto  conn = boto.connect_elb() elbs = conn.get_all_load_balancers(load_balancer_names=['my-elb-name'])[0] instances = [inst.id elb in elbs inst in elb.instances] 

Comments