Amazon Elastic Compute Cloud
User Guide (API Version 2012-05-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Bundling Amazon EC2 instance store-backed Windows AMIs

You can create Amazon EC2 instance store-backed AMIs with Windows systems. Because you can't create Amazon EC2 instance store-backed Windows AMIs from scratch, you must start with a Windows instance, customize it to meet your requirements, and then use the command line tools, the API, or console to bundle the instance and register the image.

[Note]Note

Before bundling an instance, you can configure the instance using the EC2Config service. For more information, see Appendix C: Windows Configuration Service.

For information about Windows instance types, see Windows Instance Types. For information about connecting to Windows instances, see Connecting to Windows Instances

The following diagram shows the general tasks in bundling Amazon EC2 instance store-backed Windows AMIs.

Process to create Amazon EC2 instance store-backed Windows AMI

After you've prepared your instance, the bundling process performs the following tasks, which are listed in the order that they usually take place:

  • Excludes any ephemeral drives (i.e., the D: drive on your instance is not included in the bundled AMI)

  • Compresses the image to minimize bandwidth usage and storage requirements

  • Encrypts and signs the compressed image to ensure confidentiality and authenticates the image against its creator

  • Splits the encrypted image into manageable parts for upload

  • Runs sysprep to strip out computer-specific information (e.g., the MAC address and computer name) to prepare the Windows image for virtualization

  • Creates a manifest file that contains a list of the image parts with their checksums

  • Puts all the parts of the AMI into an Amazon S3 bucket you specify

[Note]Note

All Amazon EC2 instance store-backed AMIs are loaded from Amazon S3 storage. When you create the AMI, you must upload it to an existing account on Amazon S3. Amazon S3 stores data objects in buckets, which are similar in concept to directories. Buckets have globally unique names and are owned by unique AWS accounts.

[Caution]Caution

Instance store drives (e.g., the D: drive) are not included in the bundled AMI. Instance store drives and their data are deleted when the instance is terminated. You must store any data that you want to use with the new AMI on the root drive or an Amazon EBS volume. For more information about Amazon EBS volumes, see Amazon Elastic Block Store.

You cannot launch the new AMI until the bundling is complete and you have registered it. The bundling process can take time and you can monitor the task by using the ec2-describe-bundle-tasks command. While bundling is in progress, the task moves through a succession of states, including "waiting-for-shutdown," "storing," and "complete" states. The output during the process looks like this:

BUNDLE	bun-1509ed7c	i-cb2a81a0	myawsbucket	myimage	2010-03-19T08:22:48+0000	2010-03-19T08:23:50+0000	bundling	12%

When bundling is complete, the status changes to "complete."

You must register your bundled image with Amazon EC2, so Amazon EC2 can locate it and run instances based on it. You don't have to register the bundled image immediately after the bundle task completes. You can still register the bundled image even if the bundle task no longer appears in your list of completed bundle tasks (each task remains on the list for only a limited time).

[Note]Note

If you make any changes to the source image stored in Amazon S3, you must reregister the image.

How to Bundle Amazon EC2 instance store-backed Windows AMIs

You can use the AWS Management Console, command line, or API to bundle Amazon EC2 instance store-backed Windows AMIs.

AWS Management Console

Bundling and registering Amazon EC2 instance store-backed Windows images using the console is easy. You can click buttons for each task.

To bundle Amazon EC2 instance store-backed AMIs

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

    Decide on the Windows instance you want to use, and prepare the instance to meet your specifications.

    For information about running an instance, see Running an Instance.

  2. Right-click the instance you customized and select Bundle Instance (S3 AMI).

    The Bundle Instance dialog box opens. It shows the ID of the instance you want to bundle.

  3. Provide your Amazon S3 Key Name and the Amazon S3 Bucket Name where you want the new AMI to be stored, and then click Bundle.

    You should see the Bundle Instance message box informing you that you successfully made the bundling request. The message box also provides the Bundle Task ID.

    Click View Bundling Tasks to see the status of the task. Click Close to close the message box.

    [Note]Note

    The Bundle Tasks status can show waiting-for-shutdown when Amazon EC2 is bundling an Amazon EC2 instance store-backed instance. Amazon EC2 shuts down the instance, bundles it, and puts the new bundle into Amazon S3.

  4. Navigate to the list of your AMIs when the bundling task is complete, right-click the newly-bundled AMI, and then select Register New AMI.

    The Register Image dialog box opens. Provide the AMI Manifest Path and click Register.

Command Line Tools

To bundle Amazon EC2 instance store-backed AMIs

  1. Log in to the Windows instance and modify it to meet your requirements.

    [Note]Note

    We highly recommend that you change the password of the AMI. If you use the Amazon EC2-provided password, write it down so you can access instances launched from this AMI. You cannot get the password of new instances using the ec2-get-password command.

  2. If you want to reduce your startup time, delete any temporary files on your instance using the Disk Cleanup tool, defragment your system using Disk Defragmenter, and zero out free space using sdelete -c C:\.

    You can download the sdelete utility from the sdelete Download Page or the Microsoft Web Site .

  3. Enter the following command to bundle the instance into Amazon S3 on your local system where you have installed the API tools (not on the instance you are bundling):

    PROMPT> ec2-bundle-instance <instance_id> -b <bucket_name> -p <bundle_name> -o <access_key_id> -w <secret_access_key> 

    The <instance_id> is the name of the instance, <bucket_name> is the name of the bucket in which to store the AMI, and <bundle_name> is the common name for the files to store in Amazon S3.

    [Note]Note

    To perform this task, you need your AWS Access Key ID (<aws-access-key-id>) and AWS Secret Access Key (<aws-secret-access-key>). For more information, see How to Get Your Access Key ID and Secret Access Key.

    The ec2-bundle-instance utility uploads the bundled AMI to a specified bucket. If you have used Amazon S3 before, you can use any of your existing buckets or just give ec2-bundle-instance any name that makes sense to you. If the specified bucket does not exist, the command creates it. If the specified bucket belongs to another AWS account, ec2-bundle-instance fails, and you have to specify a different name.

    The following is an example of a fully specified ec2-bundle-instance command.

    PROMPT> ec2-bundle-instance -31c2425a -b myawsbucket -p myimage -o AKIAIOSFODNN7EXAMPLE -w wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
    BUNDLE  bun-e3a4418a   i-31c2425a      myawsbucket myimage 2010-03-19T08:22:48+0000	2010-03-19T08:22:48+0000        pending

    Amazon EC2 shuts down the instance, saves it as an AMI, and restarts it.

  4. Enter the following command to register the image:

    PROMPT> ec2-register <your-s3-bucket>/image.manifest.xml -n image_name
    IMAGE ami-2bb65342 

    Amazon EC2 returns an AMI identifier, the value next to the IMAGE tag (ami-2bb65342 in the example) that you can use to run instances.

API

The following procedure mirrors the steps used with the command line tools.

To bundle Amazon EC2 instance store-backed AMIs

  1. Log in to the Windows instance and modify it to meet your requirements.

  2. Construct the following request to bundle the instance into Amazon S3 on your local system where you have installed the API tools (not on the instance you are bundling):

    https://ec2.amazonaws.com/
    ?Action=BundleInstance
    &InstanceId=-i-e468cd8d
    &Storage.S3.AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
    &Storage.S3.Bucket=myawsbucket 
    &Storage.S3.Prefix=winami
    &Storage.S3.UploadPolicy=eyJleHBpcmF0aW9uIjogIjIwMDgtMDgtMzBUMDg6NDk6MDlaIiwiY29uZGl0aW9ucyI6IFt7ImJ1Y2tldCI6ICJteS1idWNrZXQifSxbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAibXktbmV3LWltYWdlIl0seyJhY2wiOiAiZWMyLWJ1bmRsZS1yZWFkIn1dfEXAMPLE
    &Storage.S3.UploadPolicySignature=fh5tyyyQD8W4COEthj3nlGNtJMU%3D 
    &AuthParams
    [Note]Note

    To perform this task, you need your AWS Access Key ID (<aws-access-key-id>) and AWS Secret Access Key (<aws-secret-access-key>). For more information, see How to Get Your Access Key ID and Secret Access Key.

    For information about the BundleInstance command, see BundleInstance in the Amazon Elastic Compute Cloud API Reference.

  3. Construct the following command to register the image:

    https://ec2.amazonaws.com/
    ?Action=RegisterImage
    &ImageLocation=full-path-to-amazon-manifest
    &AuthParams

    Amazon EC2 returns an AMI identifier that you can use to run instances.