Skip to content

Instantly share code, notes, and snippets.

@wehappyfew
Last active August 29, 2015 14:17
Show Gist options
  • Save wehappyfew/b56e51750929725558a8 to your computer and use it in GitHub Desktop.
Save wehappyfew/b56e51750929725558a8 to your computer and use it in GitHub Desktop.
def list_all_instances(region):
# make the connection to AWS with my creds
conn = boto.ec2.connect_to_region(region_name = region,
aws_access_key_id = aws_access_key_id,
aws_secret_access_key = aws_secret_access_key,
)
reservations = conn.get_all_instances()
for r in reservations:
for instance in r.instances:
print "Reservation:"+str(r.id)+"\n", "Instance:"+str(instance.id), instance.state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment