DeleteInstances

更新时间:
复制 MD 格式

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 you release an instance, the physical resources used by the instance are recycled. Relevant data is erased and cannot be restored.
  • After you release an instance, manual snapshots of the cloud disks attached to the instance are retained and continue to be billed. You can call the DeleteSnapshot operation to delete the snapshots.

  • After you release an instance, whether the cloud disks attached to the instance and the automatic snapshots of the disks are released is determined by the disk attributes. Before you release an instance, you can call the DescribeDisks and ModifyDiskAttribute operations to query and modify disk attributes.

    • If DeleteWithInstance is set to false for a cloud disk attached to the instance, the cloud disk is changed to a pay-as-you-go disk and retained after the instance is released. If DeleteWithInstance is set to true for the cloud disk, the disk is released together with the instance.

    • If DeleteAutoSnapshot is set to false for a cloud disk attached to the instance, the automatic snapshots of the disk are retained when the instance is released. If DeleteAutoSnapshot is set to true for the cloud disk, the automatic snapshots of the disk are released together with the instance.

  • Elastic IP addresses (EIPs) are not released together with instances. You can call the ReleaseEipAddress operation to release EIPs.

Note

When you release an instance that is locked for security reasons, the cloud disks attached to the instance are released together with the instance even if DeleteWithInstance is set to false for the disks.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:DeleteInstances

delete

*Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

None None

Request parameters

Parameter

Type

Required

Description

Example

DryRun

boolean

No

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

Force

boolean

No

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 Force 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

ForceStop

boolean

No

Specifies whether to forcefully stop the ECS instance in the Running (Running) state before the instance is released. This parameter takes effect only when Force is set to true. Valid values:

  • true: forcefully stops and releases the ECS instance. In this case, this operation is equivalent to a power-off operation. The instance directly enters the resource release process.

    **

    Warning A forceful stop and release is equivalent to a power-off operation. Temporary data in the memory and storage of the instance is erased and cannot be restored.

  • false: stops the ECS instance in the normal stop process and then releases the instance. In this case, the release process takes several minutes to complete. You can configure business drainage actions to reduce the noise of the business system on operating system shutdown.

Default value: true.

true

TerminateSubscription

boolean

No

Specifies whether to release the expired subscription instance.

  • true

  • false

Default value: false.

false

ClientToken

string

No

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

RegionId

string

Yes

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

cn-hangzhou

InstanceId

array

Yes

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

i-bp1g6zv0ce8oghu7****

string

No

The ID of the ECS instance.

i-bp1g6zv0ce8oghu7****

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

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

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter.CrossRegionNotSupport Instances of multiple regions not support.
400 DRYRUN.SUCCESS This request is a dryrun request with successful result. The request is checked and determined as valid.
400 DependencyViolation.SLBConfiguring Specified operation is denied as your instance is using by another product.
400 DependencyViolation.RouteEntry Specified instance is used by route entry. Custom route entries exist in the VPC and the VPC cannot be deleted.
500 InvalidParameter Invalid parameters.
500 InternalError The request processing has failed due to some unknown error.
403 InvalidParameter.TooManyInstanceIds Instance ids cannot be more than 100. InstanceIds cannot be more than 100.
403 InvalidInstanceIds.ValueNotSupported The specified instanceIds is not valid.
403 InvalidOperation.DeletionProtection The operation is not allowed due to deletion protection. Instance has release protection turned on, so this operation cannot be performed
403 ChargeTypeViolation %s The payment type conflicts. This operation is not supported for resources of the payment type.
403 IncorrectInstanceStatus.Initializing %s
403 InvalidOperation.EniLinked %s The 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.
403 IncorrectInstanceStatus %s The instance is in a state that does not support the current operation.
403 InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons.
403 OperationDenied.SystemInstanceNotSupport The system instance does not support the %s operation because %s.
404 InvalidInstanceIds.NotFound The 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.
404 InvalidInstanceId.NotFound %s

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.