create_image ( $instance_id, $name, $opt )

Creates an Amazon EBS-backed AMI from a “running” or “stopped” instance. AMIs that use an Amazon EBS root device boot faster than AMIs that use instance stores. They can be up to 1 TiB in size, use storage that persists on instance failure, and can be stopped and started.

Access

public

Parameters

Parameter

Type

Required

Description

$instance_id

string

Required

The ID of the instance from which to create the new image.

$name

string

Required

The name for the new AMI being created.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • Description - string - Optional - The description for the new AMI being created.
  • NoReboot - boolean - Optional - By default this property is set to false, which means Amazon EC2 attempts to cleanly shut down the instance before image creation and reboots the instance afterwards. When set to true, Amazon EC2 will not shut down the instance before creating the image. When this option is used, file system integrity on the created image cannot be guaranteed.
  • BlockDeviceMapping - array - Optional - The BlockDeviceMappingItemType data type.
    • x - array - Optional - This represents a simple array index.
      • VirtualName - string - Optional - Specifies the virtual device name.
      • DeviceName - string - Optional - Specifies the device name (e.g., /dev/sdh).
      • Ebs - array - Optional - Specifies parameters used to automatically setup Amazon EBS volumes when the instance is launched.
        • x - array - Optional - This represents a simple array index.
          • SnapshotId - string - Optional - The ID of the snapshot from which the volume will be created.
          • VolumeSize - integer - Optional - The size of the volume, in gigabytes.
          • DeleteOnTermination - boolean - Optional - Specifies whether the Amazon EBS volume is deleted on instance termination.
          • VolumeType - string - Optional - [Allowed values: standard, io1]
          • Iops - integer - Optional -
      • NoDevice - string - Optional - Specifies the device name to suppress during instance launch.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Create and register a new image from a running, EBS-backed instance.

Note: This will not work on S3-backed AMIs.

// Instantiate the class
$ec2 = new AmazonEC2();

$response = $ec2->create_image('i-1d549377', 'my-ebs-image');

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/ec2.class.php | Toggle source view (17 lines) | View on GitHub

public function create_image($instance_id, $name, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['InstanceId'] = $instance_id;
    $opt['Name'] = $name;
    
    // Optional list + map
    if (isset($opt['BlockDeviceMapping']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'BlockDeviceMapping' => $opt['BlockDeviceMapping']
        )));
        unset($opt['BlockDeviceMapping']);
    }

    return $this->authenticate('CreateImage', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback