Create Image operation for the Amazon EC2 REST adapter

The Create Image operation creates an Amazon Machine Image (AMI) that uses an Amazon Elastic Block Store (EBS) root device from a running or stopped instance.

The following figure shows a sample <items> XML element for the Create Image operation:

Sample <items> XML element for the Create Image operation
<items>
 <item>
 <parameters>
 <instance-id></instance-id>
 <name></name>
 <!-Optional:->
 <description></description>
 <!-Optional:->
 <no-reboot></no-reboot>
 <block-device-mapping>
 <item>
 <device-name></device-name>
 <!- Specify any one of the following three.->
 <ebs>
 <snapshot-id></snapshot-id>
 <volume-size></volume-size>
 <volume-type></volume-type>
 <iops></iops>
 <delete-on-termination></delete-on-termination>
 </ebs>
 <no-device></no-device>
 <virtual-name></virtual-name>
 </item>
 </block-device-mapping>
 </parameters>
 </item>
</items>


The following table shows the adapter request elements for the Create Image operation:

Adapter request elements for the Create Image operation

Element

Definition

Required

<access-key>

Specifies the Amazon Web Services (AWS) access key

You need to generate the AWS access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Access Key is specified, the adapter ignores the value.
<secret-key>

Specifies the AWS secret access key

You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Secret Access Key is specified, the adapter ignores the value.
<region>

Specifies the region with which you want the adapter to communicate

Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions.

Valid values:

  • us-east-1
  • us-west-2 (default)
  • us-west-1
  • eu-west-1
  • ap-southeast-1
  • ap-northeast-1
  • ap-southeast-2
  • sa-east-1
No

<operation-name>

Contains the name of the operation: create-image

Yes

<instance-id>

Contains the ID of the instance

Yes

<name>

Contains the name of the AMI

Yes

<description>

Contains the description of the AMI

No

<no-reboot>

Specifies whether Amazon EC2 attempts to cleanly shut down the instance before creating the image and reboots the instance later (when set to false)

Valid values: true, false (default)

When this element is set to true:

  • Amazon EC2 does not shut down the instance before creating the image
  • File system integrity on the created image is not guaranteed

No

<block-device-mapping>

Specifies how block devices are exposed to the instance

Each mapping consists of a deviceName and a blockDevice.

No
<device-name>

Specifies the name of the physical device on the instance to map

For example, /dev/sdh

Conditional; required if you specify the <block-device-mapping> element
<ebs>

Specifies the parent element that contains the following elements used to set up Amazon EBS volumes to be mapped to the device:

  • <snapshot-id>
  • <volume-size>
  • <volume-type>
  • <iops>
  • <delete-on-termination>

No

Note: You can specify only one of the following elements within the <block-device-mapping> element:

  •  <ebs>
  • <no-device>
  • <virtual-name>
<snapshot-id>Specifies the snapshot ID based on which a volume is createdNo
<volume-size>Specifies the volume size that you can use instead of the <snapshot-id> to create an empty Amazon EBS volumeNo
<volume-type>Specifies the type of the volume

Valid values: io1 (To create a Provisioned IOPS volume), standard (default) 

Note: If the volume type is io1, you can also provision the number of IOPS that the volume supports.
No
<iops>Specifies the number of Input/Output operations per second (IOPS) that a volume of type I/O 1 supportsNo
<delete-on-termination>

Specifies whether to prevent the volume from being deleted on termination of the instance

Valid values: true (default), false

No
<no-device>Specifies the device to suppress during the instance launch

No

Note: You can specify only one of the following elements within the <block-device-mapping> element:

  •  <ebs>
  • <no-device>
  • <virtual-name>
<virtual-name>

Specifies an instance store volume to be mapped to the device

For example, ephemeral0

No

Note: You can specify only one of the following elements within the <block-device-mapping> element:

  •  <ebs>
  • <no-device>
  • <virtual-name>

The following figure shows a sample adapter request for the Create Image operation:

Sample adapter request for the Create Image operation

 <amazon-ec2-rest-request>
    <operation-name>create-image</operation-name>
    <parameters>
      <instance-id>i-65be346c</instance-id>
      <name>test image2</name>
      <description>Image description new</description>
      <no-reboot>false</no-reboot>
      <block-device-mapping>
        <item>
          <device-name>/dev/sda1</device-name>
          <ebs>
            <snapshot-id />
            <volume-size>8</volume-size>
            <volume-type>standard</volume-type>
            <iops />
            <delete-on-termination>true</delete-on-termination>
          </ebs>
        </item>
      </block-device-mapping>
    </parameters>
  </amazon-ec2-rest-request>

The following figure shows a sample adapter response for the Create Image operation:

Sample adapter response for the Create Image operation

 <amazon-ec2-rest-response>
  <metadata>
    <status>success</status>
  </metadata>
  <CreateImageResponse>
    <ImageInfo>
      <imageId>ami-b8cea688</imageId>
    </ImageInfo>
  </CreateImageResponse>
</amazon-ec2-rest-response>
Was this page helpful? Yes No Submitting... Thank you

Comments