Last active
August 29, 2015 14:03
-
-
Save twexler/a63462d2a414d83f7bc9 to your computer and use it in GitHub Desktop.
get all names from running instances that have a tag
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 = boto.connect_ec2() | |
ec2_hosts = [ec2.get_all_tags(filters={'resource-id': i.id, 'key': 'Name'})[0].value for i in list(itertools.chain.from_iterable([res.instances for res in ec2.get_all_instances(filters={"tag-key": "server_env", "instance-state-code": 16})]))]ec2_hosts = [ec2.get_all_tags(filters={'resource-id': i.id, 'key': 'Name'})[0].value for i in list(itertools.chain.from_iterable([res.instances for res in ec2.get_all_instances(filters={"tag-key": "server_env", "instance-state-code": 16})]))]ec2_hosts = [ec2.get_all_tags(filters={'resource-id': i.id, 'key': 'Name'})[0].value for i in list(itertools.chain.from_iterable([res.instances for res in ec2.get_all_instances(filters={"tag-key": "server_env", "instance-state-code": 16})]))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment