attach_volume ( $volume_id, $instance_id, $device, $opt )

Attach a previously created volume to a running instance.

Access

public

Parameters

Parameter

Type

Required

Description

$volume_id

string

Required

The ID of the Amazon EBS volume. The volume and instance must be within the same Availability Zone and the instance must be running.

$instance_id

string

Required

The ID of the instance to which the volume attaches. The volume and instance must be within the same Availability Zone and the instance must be running.

$device

string

Required

Specifies how the device is exposed to the instance (e.g., /dev/sdh).

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

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Attach an EBS volume to a running instance.

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

// Attach the volume
$response = $ec2->attach_volume('vol-fc482995', 'i-1f549375', '/dev/sdg');

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

Related Methods

Source

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

public function attach_volume($volume_id, $instance_id, $device, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['VolumeId'] = $volume_id;
    $opt['InstanceId'] = $instance_id;
    $opt['Device'] = $device;
    
    return $this->authenticate('AttachVolume', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback