Archive

Posts Tagged ‘AWS’

Sharing Amazon AMI with other Users

December 16, 2009 1 comment

Follow the below steps to share your owned Amazon AMI with other user.

AMIs can be listed with ec2-describe-images command of ec2 api.

The flag “-o self” is used to list only images owned by us.

Prompt> ec2-describe-images -o self
IMAGE ami-4ac2529b my-bucket/ubuntu-base.manifest.xml 495219955132 available private
IMAGE ami-5ad964c3 my-bucket/windows-server.manifest.xml 495219955132 available private

Launch permissions for an image are set by modifying an AMIs launch permission attribute.

To make the Ubuntu image public, we add all to the launch permission attribute.

Prompt> ec2-modify-image-attribute ami-4ac2529b --launch-permission --add all
launchPermission ami-4ac2529b ADD group all

Now we want to give a specific user access to windows server.

We do this by adding only his AWS account ID to the launch permission attribute.

In this example, we use the short hand forms of –launch-permission and –add.

Prompt> ec2-modify-image-attribute ami-5ad964c3 -l -a 349782532074
launchPermission ami-5ad964c3 ADD userId 349782352074

NOTE: Instead of “-a” we can use “-r” to remove / revoke launch permissions from the user.

Launch permissions on an AMI can be checked at any time by running ec2-describe-image-attribute.

$ ec2-describe-image-attribute ami-4ca2529b -l
launchPermission ami-4ca2529b group all

3 steps to Bundle Amazon EC2 Image

December 14, 2009 Leave a comment

Following are the 3 easy steps to bundle an Amazon EC2 Instance to an AMI (Amazon Image)

These steps require Amazon EC2 API tools to be installed on your system.

<and private key, certificate and access keys for your AWS account>

Step 1.

Login to the Unix / Linux instance and run the following command to create a bundle

Prompt> ec2-bundle-vol --destination /mnt/bundle-image/ 
 --prefix <target image prefix> 
 --cert <Path to X509 Certificate> 
 --privatekey <Path to X509 private key > 
 --user <AWS Account Number> 
 --exclude <exclude dir if any>

Step 2.

Execute following command to upload the Bundled Image to Amazon S3 Bucket –

Prompt>ec2-upload-bundle 

-b $bucket

-m /mnt/bundle-image/$prefix.manifest.xml

-a $AWS_ACCESS_KEY_ID

-s $AWS_SECRET_ACCESS_KEY

Step 3.

Now that the AMI files have been uploaded to S3, you register the image as a new AMI.

This is done back with the EC2 API tools installed:

Prompt> ec2-register $bucket/$prefix.manifest.xml
Categories: AWS AMI, AWS EC2 Tags: , , ,