Last active
August 29, 2015 14:02
-
-
Save gene1wood/f073bdfe5b2ad6bbf513 to your computer and use it in GitHub Desktop.
Fetch all instances across all regions
This file contains 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.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