Created
February 14, 2013 01:05
-
-
Save torufurukawa/4949837 to your computer and use it in GitHub Desktop.
Get running instance names on EC2
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.ec2 | |
c = boto.ec2.connect_to_region('ap-northeast-1', | |
aws_access_key_id=aws_access_key_id, | |
aws_secret_access_key=aws_secret_access_key) | |
reservations = c.get_all_instances() | |
instances = [item for sublist in reservations for item in sublist.instances] | |
for instance in instances: | |
if instance.state != 'running': | |
continue | |
print instance.tags.get('Name') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment