bundle_instance ( $instance_id, $policy, $opt )

The BundleInstance operation request that an instance is bundled the next time it boots. The bundling process creates a new image from a running instance and stores the AMI data in S3. Once bundled, the image must be registered in the normal way using the RegisterImage API.

Access

public

Parameters

Parameter

Type

Required

Description

$instance_id

string

Required

The ID of the instance to bundle.

$policy

array

Required

The details of S3 storage for bundling a Windows instance. Takes an associative array of parameters that can have the following keys:

  • Bucket - string - Optional - The bucket in which to store the AMI. You can specify a bucket that you already own or a new bucket that Amazon EC2 creates on your behalf. If you specify a bucket that belongs to someone else, Amazon EC2 returns an error.
  • Prefix - string - Optional - The prefix to use when storing the AMI in S3.
  • AWSAccessKeyId - string - Optional - The Access Key ID of the owner of the Amazon S3 bucket. Use the CFPolicy::get_key() method of a CFPolicy instance.
  • UploadPolicy - string - Optional - A Base64-encoded Amazon S3 upload policy that gives Amazon EC2 permission to upload items into Amazon S3 on the user’s behalf. Use the CFPolicy::get_policy() method of a CFPolicy instance.
  • UploadPolicySignature - string - Optional - The signature of the Base64 encoded JSON document. Use the CFPolicy::get_policy_signature() method of a CFPolicy instance.

$opt

array

Optional

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

  • 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 is useful for manually-managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Bundle a running Windows-based instance.

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

// Create the S3 policy
$policy = new CFPolicy($ec2, array(
	'expiration' => $ec2->util->convert_date_to_iso8601('+12 hours'), // Expire in 12 hours
	'conditions' => array(
		array('acl' => 'public-read'),
		array('bucket' => 'my-bucket')
	)
));

// Bundle the Windows instance
$response = $ec2->bundle_instance($instance_id, array(
	'Bucket' => 'my-bucket',
	'Prefix' => 'windows',
	'AWSAccessKeyId' => $policy->get_key(),
	'UploadPolicy' => $policy->get_policy(),
	'UploadPolicySignature' => $policy->get_policy_signature()
));

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

Related Methods

Source

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

public function bundle_instance($instance_id, $policy, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['InstanceId'] = $instance_id;

    $opt = array_merge($opt, CFComplexType::map(array(
        'Storage.S3' => $policy
    )));

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

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback