Last active
August 29, 2015 14:03
-
-
Save robbwagoner/f77ea0343fba0a8ec425 to your computer and use it in GitHub Desktop.
List all the paravirtualized 64-bit Amazon-owner AMIs
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
#!/usr/bin/env bash | |
set -e | |
# Reference: | |
# AWS EC2 Docs: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html | |
# AWS CLI: http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.html | |
# | |
# Notes: | |
# As-of 2014-07-08, the latest amzn ami: amzn-ami-pv-2014.03.1.x86_64-ebs | |
# AWS CLI command | |
#aws --region $region ec2 describe-images \ | |
# --owners amazon \ | |
# --filters \ | |
# "Name=virtualization-type,Values=paravirtual" \ | |
# "Name=root-device-type,Values=ebs" \ | |
# "Name=architecture,Values=x86_64" | |
# TODO: pure Python | |
# AWS AMI List with JSON decoding by Python | |
export region=eu-west-1 | |
python - 3< <( | |
aws --region $region ec2 describe-images \ | |
--owners amazon \ | |
--filters \ | |
"Name=virtualization-type,Values=paravirtual" \ | |
"Name=root-device-type,Values=ebs" \ | |
"Name=architecture,Values=x86_64") <<EOF | |
import os, sys, json | |
region = os.environ['region'] | |
fd3 = os.fdopen(3,'r') | |
amis = json.load(fd3) | |
for ami in amis["Images"]: | |
try: | |
print "{region}:{imageid}:{name}:{description}".format(region=region,name=ami['Name'],imageid=ami['ImageId'],description=ami['Description']) | |
except KeyError: | |
print "{region}:{imageid}:{name}:no_description".format(region=region,name=ami['Name'],imageid=ami['ImageId']) | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment