detach_volume ( $volume_id, $opt )

Detach a previously attached volume from a running instance.

Access

public

Parameters

Parameter

Type

Required

Description

$volume_id

string

Required

The ID of the volume to detach.

$opt

array

Optional

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

  • InstanceId - string - Optional - The ID of the instance from which to detach the the specified volume.
  • Device - string - Optional - The device name to which the volume is attached on the specified instance.
  • Force - boolean - Optional - Forces detachment if the previous detachment attempt did not occur cleanly (logging into an instance, unmounting the volume, and detaching normally). This option can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance will not have an opportunity to flush file system caches nor file system meta data. If you use this option, you must perform file system check and repair procedures.
  • 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

Detach an EBS volume from a running instance.

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

// Detach the volume
$response = $ec2->detach_volume($volume_id, array(
	'InstanceId' => 'i-1f549375',
	'Device' => '/dev/sdg'
));

// 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 detach_volume($volume_id, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['VolumeId'] = $volume_id;
    
    return $this->authenticate('DetachVolume', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback