Last Updated: February 25, 2016
·
719
· garnaat

Get all Instance objects from Reservations

In boto, getallinstances() returns those annoying Reservation objects when what you really want are the Instance objects. Here's a nice concise way to extract the Instances.

import boto
ec2 = boto.connect_ec2()
reservations = ec2.get_all_instances()
instances = [i for r in reservations for i in r.instances]