Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gene1wood/f073bdfe5b2ad6bbf513 to your computer and use it in GitHub Desktop.
Save gene1wood/f073bdfe5b2ad6bbf513 to your computer and use it in GitHub Desktop.
Fetch all instances across all regions
import boto.ec2
import sys
from pprint import pprint
all_regions = [x.name for x in
boto.ec2.connect_to_region('us-east-1').get_all_regions()]
instances=[]
for region in all_regions:
instances.extend(boto.ec2.connect_to_region(region).get_only_instances())
instance = next((x for x in instances if x.id == sys.argv[1]), None)
pprint(vars(instance) if instance else 'id not found')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment