Last active
December 13, 2015 23:29
-
-
Save rberrelleza/4991686 to your computer and use it in GitHub Desktop.
Python script to get all the valid windows AMI from an AWS region
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 | |
if __name__ == '__main__': | |
zones = ['us-east-1', 'us-west-2', 'us-west-1', 'eu-west-1', 'ap-southeast-1', | |
'ap-northeast-1', 'ap-southeast-2', 'sa-east-1'] | |
for zone in zones: | |
connection = boto.ec2.connect_to_region( | |
region_name=zone, | |
aws_access_key_id='AMAZON_KEY', | |
aws_secret_access_key='AMAZON_ACCESS_KEY') | |
images = connection.get_all_images( | |
filters={ | |
'owner_alias':'amazon', 'platform':'windows', 'state':'available'}) | |
if images is not None: | |
for i in images: | |
if i is not None and i.name is not None: | |
if 'Windows_Server-2012-RTM-English-64Bit-Base' in i.name: | |
print i.id | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment