Created
January 11, 2012 19:57
-
-
Save garnaat/1596459 to your computer and use it in GitHub Desktop.
Retrieve full Instance info from an InstanceInfo object returned by ELB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto | |
elb = boto.connect_elb() | |
ec2 = boto.connect_ec2() | |
load_balancers = elb.get_all_load_balancers() | |
# | |
# The InstanceInfo object in the LoadBalancer object contains only a small subset | |
# of information about the Instance. To get the full set of information, you have | |
# to retrieve the full Instance object. | |
# Let's retrieve the full Instance information for all instances associated with the | |
# first load balancer in the list | |
instance_ids = [i.id for i in load_balancers[0].instances] | |
reservations = ec2.get_all_instances(instance_ids) | |
instances = [r.instances[0] for r in reservations] | |
# instances now contains the complete Instance object for each instance object | |
# in the first load balancer. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment