You can call the DeleteInstances action to release one or more pay-as-you-go or expired subscription ECS instances.

Description

  • For an ECS instance with security control enabled and with the "LockReason" : "security" tag inOperationLocks, attached data disks are released even if DeleteWithInstance of attached data disks is set to False.
  • If one of the specified ECS instances cannot be released, the value of TaskStatus is Failed. You can call the DescribeTaskAttribute operation to check TaskStatus based on the returned value of TaskId.
  • After an instance is released, all of its physical resources are reclaimed. All data is erased and cannot be restored. The attached data disks with DeleteWithInstance=True are released, but their automatic snapshots are retained. Whether automatic snapshots are deleted depends on the value of DeleteAutoSnapshot. In the case of DeleteAutoSnapshot=false, the automatic snapshots are retained. In the case of DeleteAutoSnapshot=true, the automatic snapshots are released.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
InstanceId.N RepeatList Yes i-instanceid1

The ID of the instance. Valid values of N: 1 to 100.

Action String No DeleteInstances

The operation that you want to perform. For API requests using the HTTP or HTTPS methods, Action is required. Set the value to DeleteInstances.

TerminateSubscription Boolean No false

Specifies whether to release expired subscription instances.

Default value: false.

Force Boolean No false

Specifies whether to forcibly release instances which are in the Running state. Default value: false. Valid values:

  • true: forcibly releases instances which are in the Running state. When this value is selected, temporary data in the memory and storage for the instance is erased and cannot be restored.
  • false: This value can only be selected for instances in the Stopped state.
DryRun Boolean No false

Specifies whether to perform check only. Default value: false. Valid values:

  • true: A check request is sent. The resource status is not queried. The system checks whether your AccessKey pair is valid, whether RAM users are authorized, and whether the required parameters are set. If the check fails, the corresponding error message is returned. Otherwise, the DryRunOperation error code is returned.
  • false: A request is sent. After a successful check, the 2XX HTTP status code is returned and resource status is queried.
token String No 123e4567-e89b-12d3-a456-426655440000

A client token. It is used to guarantee the idempotency of requests. The value of this parameter is generated by the client and is unique among different requests. The ClientToken parameter can only contain ASCII characters and cannot exceed 64 characters in length.

Response parameters

Parameter Type Example Description
RequestId String 7B7813C6-57BF-41XX-B12B-F172F65A6046

The ID of the request.

TaskId String t-bp11og034hlx2died***

The ID of the task. You can call the DescribeTaskAttribute operation to query the progress of the ECS instance release task.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=DeleteInstances
&InstanceId.1=i-instance1
&Force=false
&<Common request parameters>

Successful sample responses

XML format

<DeleteInstancesResponse>
      <RequestId>7B7813C6-57BF-41XX-B12B-F172F65A6046</RequestId>
      <TaskId>t-bp11og034hlx2died***</TaskId>
</DeleteInstancesResponse>

JSON format

{
	"RequestId":"7B7813C6-57BF-41XX-B12B-F172F65A6046",
	"TaskId":"t-bp11og034hlx2died***"
}

Error codes

HTTP status code Error code Error message Description
403 InvalidOperation.NotInWhiteList %s The error message returned because you have no privilege to perform the operation.
403 InvalidOperation.DeletionProtection %s The error message returned because release protection is enabled for the instance.
403 IncorrectInstanceStatus %s The error message returned because the operation is not supported while the instance is in the current state.
403 IncorrectInstanceStatus The current status of the resource does not support this operation. The error message returned because the operation is not supported while the instance is in the current state.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred. Try again later. If the problem persists, submit a ticket.
500 InternalError %s The error message returned because an internal error has occurred.
403 InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons. The error message returned because the operation is not supported while the instance is locked.
400 DependencyViolation.SLBConfiguring Specified operation is denied as your instance is using by another product. The error message returned because the instance is referenced by an SLB instance that is undergoing configuration.
400 DependencyViolation.RouteEntry Specified instance is used by route entry. The error message returned because custom routing rules still exist in the VPC.

For more information about error codes, see API Error Center.