Detach Volume operation for the Amazon EC2 REST adapter


The Detach Volume operation detaches an Amazon EBS volume from an instance.

Ensure that you unmount any file systems on the device within your operating system before detaching the volume. Failure to do so will result in the volume being stuck in "busy" state while detaching. If an Amazon EBS volume is the root device of an instance, it cannot be detached while the instance is in the running state. To detach the root volume, stop the instance first. If the root volume is detached from an instance with an Amazon Web Service (AWS) Marketplace product code, then the AWS Marketplace product codes from that volume are no longer associated with the instance.

The following figure shows a sample <items> XML element for the Detach Volume operation. 

Sample <items> XML element for the Detach Volume operation

<items>
   <item>
       <parameters>
           <volume-id></volume-id>
           <!--Optional:-->
           <instance-id></instance-id>
           <!--Optional:-->
           <device></device>
           <!--Optional:-->
           <force></force>
       </parameters>
   </item>
</items>

The following table shows adapter request elements for the Detach Volume operation. 

Adapter request elements for the Detach Volume operation 

Element

Definition

Required

<access-key>

Specifies the Amazon Web Services (AWS) access key

You need to generate the AWS access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Access Key is specified, the adapter ignores the value.
<secret-key>

Specifies the AWS secret access key

You need to generate the AWS secret access key by going to the Security Credentials tab in the AWS console.

Conditional;

  • You must specify the Access Key and theSecret Key together in the configuration or the adapter request.
  • If you specify both the keys in the adapter request and in the adapter configuration, the key values in the request override the values in the configuration.
  • If only the Secret Access Key is specified, the adapter ignores the value.
<session-token>

Specifies the temporary session token generated using the AWS APIs.

Conditional;

You must specify the Access Key and Secret Key as well in the configuration or the adapter request, else the <session-token> value is ignored.

<region>

Specifies the region with which you want the adapter to communicate

Amazon EC2 is hosted in multiple locations world-wide. You must specify the region in which you want the adapter to perform the actions.

Valid values:

  • us-east-1
  • us-west-2 (default)
  • us-west-1
  • eu-west-1
  • ap-southeast-1
  • ap-northeast-1
  • ap-southeast-2
  • sa-east-1

No

<operation-name>

Contains the name of the operation: detach-volume

Yes

<volume-id>

Specifies the ID of the Amazon EBS volume that you want to detach

Yes

<instance-id>

Specifies the ID of the instance from which the volume is detached

No

<device>

Specifies the name of the device

No

<force>

Forces detachment if the previous detachment attempt did not occur cleanly (logging into an instance, unmounting the volume, and detaching normally)

Note

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.

No

The following figure shows a sample adapter request for the Detach Volume operation. 

Sample adapter request for the Detach Volume operation

<amazon-ec2-rest-request>
   <operation-name>detach-volume</operation-name>
   <region>us-west-2</region>
   <parameters>
     <volume-id>vol-76420d78</volume-id>
     <instance-id>i-8ae53c83</instance-id>
     <device>/dev/sdf3</device>
     <force>true</force>
   </parameters>
 </amazon-ec2-rest-request>

The following figure shows a sample adapter response for the Detach Volume operation. 

Sample adapter response for the Detach Volume operation

<amazon-ec2-rest-response>
 <metadata>
   <status>success</status>
 </metadata>
 <DetachVolumeResponse>
   <volumeId>vol-76420d78</volumeId>
   <instanceId>i-8ae53c83</instanceId>
   <device>/dev/sdf3</device>
   <status>detaching</status>
   <attachmentTime>Thu Jan 09 05:19:45 EST 2014</attachmentTime>
   <deleteOnTermination />
 </DetachVolumeResponse>
</amazon-ec2-rest-response>

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*