All Products
Search
Document Center

Elastic Compute Service:DeleteInstances

Last Updated:Nov 18, 2024

Releases multiple pay-as-you-go Elastic Compute Service (ECS) instances or expired subscription ECS instances at a time. You can configure parameters to specify whether to release the disks attached to the instances or retain the disks as pay-as-you-go disks.

Operation description

**

Warning After an ECS instance is released, all physical resources used by the instance are reclaimed. Relevant data is erased and cannot be restored.

After an ECS instance is released, the manual snapshots of the disks attached to the instance are retained. Whether the disks and the automatic snapshots of the disks are released is determined by the options that you configured when you created the instance and disks. Before you release an ECS instance, you can call the DescribeDisks operation to query the parameters of the disks attached to the instance and the automatic snapshots.

  • If DeleteWithInstance is set to false, the disks are changed to pay-as-you-go disks and retained. If DeleteWithInstance is set to true, the disks are released along with the instance.
  • If DeleteAutoSnapshot is set to false, the automatic snapshots are retained. If DeleteAutoSnapshot is set to true, the automatic snapshots are released along with the instance.
Note If an ECS instance is locked for security reasons, the disks attached to the instance are released along with the instance even if DeleteWithInstance is set to false for the disks.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:DeleteInstancesdelete
*Instance
acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DryRunbooleanNo

Specifies whether to perform only a dry run, without performing the actual request.

  • true: performs only a dry run. The system checks the request for potential issues, including invalid AccessKey pairs, unauthorized Resource Access Management (RAM) users, and missing parameter values. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DRYRUN.SUCCESS error code is returned.
  • false: performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.

Default value: false.

false
ForcebooleanNo

Specifies whether to forcefully release the ECS instance in the Running (Running) state. Valid values:

  • true: forcefully releases the ECS instance in the Running (Running) state.
  • false: normally releases the ECS instance. This value is valid only if the instance is in the Stopped (Stopped) state.

Default value: false.

**

Warning When the Force parameter is set to true, this operation is equivalent to a power-off operation. Temporary data in the memory and storage of the instance is erased and cannot be restored.

false
TerminateSubscriptionbooleanNo

Specifies whether to release the expired subscription instance. Valid values:

  • true
  • false

Default value: false.

false
ClientTokenstringNo

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-426655440000
RegionIdstringYes

The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
InstanceIdarrayYes

The IDs of ECS instances. You can specify 1 to 100 ECS instances.

stringYes

The ID of the ECS instance.

i-bp1g6zv0ce8oghu7****

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The request ID.

7B7813C6-57BF-41XX-B12B-F172F65A6046

Examples

Sample success responses

JSONformat

{
  "RequestId": "7B7813C6-57BF-41XX-B12B-F172F65A6046"
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidParameter.CrossRegionNotSupportInstances of multiple regions not support.-
400DRYRUN.SUCCESSThis request is a dryrun request with successful result.The request is checked and determined as valid.
400DependencyViolation.SLBConfiguringSpecified operation is denied as your instance is using by another product.The instance is referenced by an SLB instance that is being configured.
400DependencyViolation.RouteEntrySpecified instance is used by route entry.Custom route entries exist in the VPC and the VPC cannot be deleted.
403InvalidParameter.TooManyInstanceIdsInstance ids cannot be more than 100.-
403InvalidInstanceIds.ValueNotSupportedThe specified instanceIds is not valid.-
403InvalidOperation.DeletionProtectionThe operation is not allowed due to deletion protection.-
403InvalidOperation.DeletionProtection%sThe operation is invalid. Disable release protection for the instance first.
403ChargeTypeViolation%s-
403IncorrectInstanceStatus.Initializing%s-
403InvalidOperation.EniLinked%sThe operation is invalid because the current ENI of the instance is associated with other ENIs. You must disassociate the ENI from the other ENIs before you can unbind the ENI from the instance.
403IncorrectInstanceStatus%sThe instance is in a state that does not support the current operation.
403InstanceLockedForSecurityThe specified operation is denied as your instance is locked for security reasons.-
404InvalidInstanceIds.NotFoundThe specified InstanceIds does not exist.The specified InstanceId parameter does not exist. You can call the DescribeInstances operation to query the state of the instance.
404InvalidInstanceId.NotFound%sThe specified instance does not exist. Check whether the InstanceId parameter is valid.
500InvalidParameterInvalid parameters.-
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.
500InternalError%sAn internal error has occurred.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-07-17The Error code has changedView Change Details