create_volume ( $availability_zone, $opt )

Initializes an empty volume of a given size.

Access

public

Parameters

Parameter

Type

Required

Description

$availability_zone

string

Required

The Availability Zone in which to create the new volume.

$opt

array

Optional

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

  • Size - integer - Optional - The size of the volume, in gigabytes. Required if you are not creating a volume from a snapshot.
  • SnapshotId - string - Optional - The ID of the snapshot from which to create the new volume.
  • VolumeType - string - Optional - [Allowed values: standard, io1]
  • Iops - integer - Optional -
  • 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 a new volume in the same availability zone as a running instance.

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

// Describe the running instance to get the Availability Zone
$describe = $ec2->describe_instances(array(
	'InstanceId' => 'i-1f549375'
));

// Grab the Availability Zone
$avail_zone = (string) $describe->body->availabilityZone(0); // First result of the built-in XPath search.

// Create the volume
$response = $ec2->create_volume($avail_zone, array(
	'Size' => 10 // Gibibytes
));

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

Related Methods

Source

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

public function create_volume($availability_zone, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['AvailabilityZone'] = $availability_zone;
    
    return $this->authenticate('CreateVolume', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback