Last active
December 16, 2015 08:48
-
-
Save thanos/5408040 to your computer and use it in GitHub Desktop.
FInds AWS EC2 instances with a certain tag set.
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
| def get_ec2_instances(**tags): | |
| from pprint import pprint | |
| from django.conf import settings | |
| import boto | |
| aws = boto.connect_ec2(settings.AWS_ACCESS_KEY_ID ,settings.AWS_SECRET_ACCESS_KEY) | |
| reservations = aws.get_all_instances() | |
| return [i for r in reservations = aws. for i in r.instances if set(tags.items()) & set(i.tags.item())] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment