Create Amazon EC2 AMI

Examples

aws

Creating an Amazon EC2 AMI from an existing image seems like a challenging process however, it is actually fairly simple. Before looking at the steps to create the image, first have the following AWS information/files handy:

  • Access key
  • Secret Key
  • Account Number
  • Private key (e.g., pk-37BKCPZ2AVHVSYBK2WZXUQ9D4GQZEB4Q.pem)
  • Certificate (e.g., cert-38BKCPZ1BOHVSYBK4WZXUQ4D4GQZEB2Q.pem)

Next, login to your instance and make sure you have the Amazon AMI and EC2 API tools installed and available in your PATH. Also, upload your private key and certificate to the server.

Now you are ready to create your image file. First create a directory to store this image in.

E.g.

mkdir /mnt/ami

The actual AMI bundle is created by running:

ec2-bundle-vol -d /mnt/ami -k YOUR_PRIVATE_KEY -c YOUR_CERTIFICATE -u YOUR_ACCOUNT_NUMBER

note: The account number should not contain any dashes (‘-’).

Creating the bundle takes a few minutes. After the bundle has been created, it is time to upload it to S3. This is done by running:

ec2-upload-bundle -b YOUR_BUNDLE_NAME -m /mnt/ami/image.manifest.xml -a YOUR_ACCESS_KEY -s YOUR_SECRET_KEY

This walks through the files generated by the bundle command and inserts them into S3.

After your files have been uploaded, it is time to register the AMI using the following command:

ec2-register YOUR_BUNDLE_NAME/image.manifest.xml

The result of running this command is your AMI id.

E.g.

ami-323FEA

Finally, your AMI has been created, uploaded and registered and you are able to launch a new instance of your AMI.

If you need more help, there is a good video available from an Amazon employee. Additionally, take a look at the Amazon docs on the subject.

No Comments

Leave a Reply

Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>