Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change image permission (AMI) for AWS using boto/python?

How can we change an AMI's permission to add more AWS accounts using python's boto module ?

like image 641
Pranav Avatar asked Aug 20 '14 10:08

Pranav


1 Answers

You can use the modify_image_attribute method of the boto.ec2 module to modify this and other attributes associated with an image.

You can add additional authorized users like this:

import boto.ec2

ec2 = boto.ec2.connect_to_region('<your region>')
ec2.modify_image_attribute('ami-12345678', operation='add', attribute='launchPermission', user_ids=['user_id_1', 'user_id_2'])

Similarly, you could add authorize groups using the attribute='launchPermission' and the group values in the parameter group_ids.

like image 159
garnaat Avatar answered Oct 21 '22 16:10

garnaat