Bundling an AMI
A root file system image needs to be bundled as an AMI in order to be used with the Amazon EC2
service. The bundling process first compresses the image to minimize bandwidth usage and storage
requirements. The compressed image is then encrypted and signed to ensure confidentiality of the data,
and authentication against the creator. The encrypted image is finally split into manageable parts for
upload. A manifest file is created containing a list of the image parts with their checksums. This chapter
provides an overview of the AMI tools that automate this process and some examples of their use.
The AMI tools are three command-line utilities:
1. ec2-bundle-image bundles an existing AMI
2. ec2-bundle-vol creates an AMI from an existing machine or installed volume
3. ec2-upload-bundle uploads a bundled AMI to S3 storage
Installing the AMI Tools
The AMI tools are packaged as an RPM suitable for running on Fedora Core 3/4 with Ruby 1.8.2 (or
greater) installed. On Fedora Core 4 Ruby can be installed by following the steps below. You will need
root privileges to install the software. You can find the AMI tools RPM at .
First install Ruby using the yum package manager.
# yum install ruby
Install the ec2-common-ruby RPM which contains library functions that the AMI tools depend on. The
x's represent the major version, minor version and build number of the RPMs.
# rpm -i ec2-common-ruby-x.x-xxxx.i386.rpm
Install the AMI tools RPM.
# rpm -i ec2-ami-tools-x.x-xxxx.i386.rpm
Installation Issues
The AMI tools libraries install under /usr/lib/site_ruby. Ruby should pick up this path
automatically, but if you see a load error when running one of the AMI utilities, it may be because Ruby
isn't looking there. To fix this, add /usr/lib/site_ruby to Ruby's library path, which is set in the
RUBYLIB environment variable.
Documentation
The manual describing the operation of each utility can be displayed by invoking it with the --manual
parameter. For example:
# ec2-bundle-image --manual
Invoking a utility with the --help parameter displays a summary and list of command line parameters.
For example:
# ec2-bundle-image --help
Amazon EC2
Developer Guide
10
Using the AMI Tools
Once a machine image has been created it must be bundled as an AMI for use with Amazon EC2, as
follows. Use ec2-bundle-image to bundle an image that you have prepared in a loopback file, as
described in the previous section.
# ec2-bundle-image -i my-image.img -k my-private-key.key -c my-x509-cert.cert
This will create the bundle files:
image.part.00
image.part.01
...
image.part.NN
image.manifest
Alternatively an AMI could be created by snapshotting the local machine root file system and bundling
it all at once by using ec2-bundle-vol. (note: you will need to have root privileges to do this and
SELinux must be disabled). Use ec2-bundle-vol to re-bundle a (modified) running instance of an
existing AMI, as described in the previous section.
# ec2-bundle-vol -k my-private-key.key -s 1000 -u 495219933132
As with ec2-bundle-image, ec2-bundle-vol will create image parts files and a manifest file.
Note
If selinux is enabled when ec2-bundle-vol is run, the filesystem creation step may fail. Selinux
should be disabled while this is done.
Uploading a Bundled AMI
The bundled AMI needs to be uploaded for storage in Amazon S3 before it can be accessed by
Amazon EC2. Use ec2-upload-bundle to upload the bundled AMI that you created as described above.
S3 stores data objects in buckets, which are similar in concept to directories. Buckets must have globally
unique names. The ec2-upload-bundle utility will upload the bundled AMI to a specified bucket. If the
specified bucket does not exist it will be created. However, if the specified bucket already exists, and
belongs to another user, then ec2-upload-bundle will fail.
# ec2-upload-bundle -b my-bucket -m image.manifest -a my-aws-access-key-id -s
my-secret-key-id
The AMI manifest file and all image parts are uploaded to S3. The manifest file is encrypted with the
Amazon EC2 public key before being uploaded.
Amazon EC2
Developer Guide
11
Previous Page Next Page