Amazon Elastic Compute Cloud
Microsoft Windows Guide (API Version 2012-04-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...

Creating an Instance Store-Backed Windows AMI

The process for creating an instance store-backed AMI is different from the process of creating an Amazon EBS-backed AMI. 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. We refer to this process of creating an AMI as Bundling.

[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 EC2 storage options, go to Using Storage.

You cannot launch the new AMI until the bundling is complete and you have registered the bundled image. 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.

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

Process to create Amazon EC2 instance store-backed Windows AMI

Tasks for Creating an Instance Store-Backed Windows AMI

  1. Start by launching a Windows instance that is similar to the AMI you want to create and connect to the instance. For information on connecting to a Amazon EC2 Windows instance, go to Connecting to Windows Instances.

  2. When you are connected to your instance, customize it as you want. For example, you could attach Amazon EBS volumes, or load applications or data on to the instance.

    [Important]Important

    It is very important to remember the following behavior of the instance store-backed AMI creation process on the storage drives:

    • The system drive (C:) is automatically attached when the new instances are launched. The data on the C: drive is the only one that will persist when the instance is bundled.

    • Other instance store drives (for example, D:) are temporary drives, and should be strictly used for short-term storage, since they will not persist when instance is bundled.

    • You can add Amazon EBS volumes. The EBS volumes are stored within Amazon S3 buckets and therefore will remain intact when the instance is bundled. We recommend that you store all the data that you need to persist within the Amazon EBS volumes.

  3. When an instance is launched for the first time, it goes through a cycle of configuration and Sysprep. After the instance boots, some of the configuration settings are either Enabled or Disabled to persist the settings through instance reboots. Before bundling an instance, you can configure the instance using the EC2Config Service. Use EC2Config Services tool or EC2Config XML files to change the configuration settings for your new AMI. For more information, see Using EC2Config Service. For more information about Sysprep, see Sysprep Technical Reference.

  4. Bundle and then register the AMI.

  5. 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 instance store 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

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.

Using the AWS Management Console

Bundling and registering Amazon EC2 instance store-backed Windows images using the console is easy.

To bundle an Amazon EC2 instance store-backed AMIs

  1. Log in to the AWS Management Console and click the box next to the drop-down arrow to open a list of services. Click Amazon Elastic Compute Cloud and then select the Windows instance you want to use, and prepare the instance to meet your specifications.

    For information about running an instance, go to 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.

Using 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.

    [Note]Note

    We 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 for 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 (do not enter this command on the instance you are bundling):

    C:\> 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 (access_key_id) and AWS Secret Access Key (secret_access_key). For more information, go to Amazon EC2 Credentials.

    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.

    C:\> 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:

    C:\> ec2-register myawsbucket/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.

Using Query API

The following procedure steps you through how to bundle an Amazon EC2 instance store-backed AMI. This process mirrors the steps you would use 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 (do not construct the request 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=eyJleHBpcmF0aW9uIjogIjIwMDgtMDgtMzBUMDg6NDk6MDlaIiwiY29uZGl0aW9ucyI6IFt7ImJ1Y2tldCI6ICJteS1idWNrZXQifSxbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAibXktbmV3LWltYWdlIl0seyJhY2wiOiAiZWMyLWJ1bmRsZS1yZWEXAMPLEEXAMPLE
    &Storage.S3.UploadPolicySignature=fh5tyyyQD8W4COEtxxxxxxxEXAMPLE 
    &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, go to Amazon EC2 Credentials.

    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.