Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting AWS AMI properties

I have a list of AMIs, which I got by creating a boto connection:

conn_eu = boto.ec2.connect_to_region('eu-west-1')
images = conn_eu.get_all_images(owners=['me'])

I want to be able to see the properties of these AMIs. Properties such as their descriptions, names and their image ids.

like image 936
AmirHBP Avatar asked May 04 '26 15:05

AmirHBP


1 Answers

Here are all of the properties of the boto.ec2.image.Image object per Print all properties of a Python Class:

from boto.ec2 import connect_to_region
ec2_connection = connect_to_region("us-west-2",
          aws_access_key_id="...",
          aws_secret_access_key="...")
images = ec2_connection.get_all_images(image_ids=["ami-xxxxxxxxx"])
for k in vars(images[0]).keys():
       print "{0}".format(k)

(Or, to print the values as well, you can use):

for k,v in vars(images[0]).iteritems():
       print "{0}:{1}".format(k,v)

root_device_type ramdisk_id id owner_alias billing_products tags platform state location type virtualization_type sriov_net_support architecture description block_device_mapping kernel_id owner_id is_public instance_lifecycle creationDate name hypervisor region item connection root_device_name ownerId product_codes

like image 52
storm_m2138 Avatar answered May 06 '26 06:05

storm_m2138