AttachDisk

Last Updated: Sep 13, 2017

Description

Before attaching a disk, the following prerequisites must be met:

  • The instance status must be running or stopped
  • In OperationLocks, the LockReason: security cannot be True
  • Payment cannot be overdue

On this interface, when the DeleteWithInstance property is set and the OperationLocks of the instance indicates LockReason: security, the DeleteWithInstance property of the disk will be ignored and the disk will be released along with the instance.

Request parameters

Name Type Required Description
Action String Yes Indicates the operation interface name and the required parameter, value: AttachDisk.
InstanceId String Yes Indicates the ID of the destination ECS.
DiskId String Yes Indicates the disk ID. The disk and Instance must be in the same zone.
DeleteWithInstance String No This parameter determines whether or not the disk is released along with the instance. Optional values:
  • true: Indicates that when the instance is released, the disk will be released with it.
  • false: Indicates that when the instance is released, the disk will be retained.
The default value is None. This indicates taking the current value without modification.

Return parameters

All parameters are public return parameters. For details, refer to Public Return Parameters.

Error code

Error Code Description Http status code Meaning
MissingParameter The input parameter InstanceId that is mandatory for processing this request is not supplied. 400 InstanceId is not specified.
MissingParameter The input parameter DiskId that is mandatory for processing this request is not supplied. 400 DiskId is not specified.
InvalidInstanceId.NotFound The specified InstanceId does not exist. 404 The specified instance does not exist.
InvalidDiskId.NotFound The specified disk does not exist. 404 The specified disk does not exist.
InvalidDevice.Malformed The specified device is not valid. 400 The specified disk does not exist.
InvalidParameter The specified parameter DeleteWithInstance is not valid. 400 The specified DeleteWithInstance parameter is invalid.
InstanceDiskLimitExceeded The amount of the disk on instance in question reach its limits. 403 The specified instance is already attached with the maximum number of disks.
InvalidDevice.InUse The specified device has been occupied. 403 The specified device already has an attached disk.
IncorrectDiskStatus The operation is not supported in this status. 403 The disk status is incorrect.
DiskNotPortable The specified disk is not a portable disk. 403 The specified disk cannot be detached.
InstanceLockedForSecurity The instance is locked due to security. 403 The specified instance has a safety lock.
ResourcesNotInSameZone The specified instance and disk are not in the same zone. 403 The specified disk and instance are not in the same zone.
InstanceExpiredOrInArrears The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode). 403 Payment is overdue for the specified instance.
DiskInArrears The specified operation is denied as your disk owing fee. 403 Payment is overdue for the specified disk.
IncorrectInstanceStatus The current status of the resource does not support this operation. 400 The status of the specified instance is incorrect.
DiskError IncorrectDiskStatus. 403 Abnormal disk status.

Examples

Request example

  1. https://ecs.aliyuncs.com/?action=AttachDisk
  2. &InstanceId=i-23jggx34b
  3. &DiskId=d-23jbf2v5m
  4. &<Public Request Parameters>

Return example

XML format

  1. <AttachDiskResponse>
  2. <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
  3. </AttachDiskResponse>

JSON format

  1. {
  2. "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
  3. }
Thank you! We've received your feedback.