All Products
Search
Document Center

Elastic Compute Service:DeleteInstance

Last Updated:Jun 18, 2026

Deletes or releases a specified ECS instance.

Operation description

Warning After an instance is released, all physical resources used by the instance are reclaimed. All related data is permanently lost and cannot be recovered.
.
  • Manual snapshots of disks are retained and continue to incur charges. You can delete them by calling DeleteSnapshot.

  • Whether disks attached to the instance and automatic snapshots are released depends on the parameter settings specified when they were created. Before you release an instance, you can call DescribeDisks and ModifyDiskAttribute to query and modify the related parameter settings:
    • If DeleteWithInstance=false, the disk is converted to a pay-as-you-go disk and retained. Otherwise, the disk is released along with the instance.

    • If DeleteAutoSnapshot=false, automatic snapshots are retained. Otherwise, they are released along with the instance.

  • Elastic IP addresses (EIPs) are not released along with the instance. You can call ReleaseEipAddress to release them.
    Important For a security-locked instance, even if the DeleteWithInstance parameter of a disk is set to false, this attribute is ignored and the disk is released along with the instance.
    .

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:DeleteInstance

delete

*Instance

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

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The instance ID.

i-bp1g6zv0ce8oghu7****

Force

boolean

No

Specifies whether to forcefully release a running (Running) instance.

  • true: Forcefully releases a running (Running) instance.

  • false: Releases the instance in the normal way. The instance must be in the Stopped (Stopped) state.

Default value: false.

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

false

ForceStop

boolean

No

Specifies whether to use the forced shutdown policy when releasing a running (Running) instance. This parameter takes effect only when Force=true. Valid values:

  • true: Forcefully shuts down and releases the instance. This is equivalent to a typical power-off operation. The instance directly enters the resource release process.
    Warning A forceful release is equivalent to a power-off. Temporary data in the instance memory and storage is erased and cannot be recovered.
  • false: Before the instance is released, the system preferentially performs a standard shutdown process. This mode causes the instance release to take several minutes. You can configure service draining actions during the operating system shutdown to reduce noise in your business systems.

Default value: true.

true

TerminateSubscription

boolean

No

Specifies whether to release an expired subscription instance.

  • true: Releases the instance.

  • false: Does not release the instance.

Default value: false.

false

DryRun

boolean

No

Specifies whether to perform only a dry run. Valid values:

  • true: Sends a check request without releasing the instance. The system checks whether the required parameters are specified, the request format is valid, business requirements are met, and ECS resources are sufficient. If the check fails, the corresponding error is returned. If the check succeeds, the error code DryRunOperation is returned.

  • false (default): Sends a normal request. After the request passes the check, the instance is directly deleted.

false

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Success response

JSON format

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status code

Error code

Error message

Description

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.
400 InvalidParameter The input parameter InstanceId is invalid. The specified InstanceId parameter is invalid.
500 InternalError The request processing has failed due to some unknown error.
403 IncorrectInstanceStatus The current status of the resource does not support this operation.
403 InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons.
403 ChargeTypeViolation The operation is not permitted due to charge type of the instance.
403 IncorrectInstanceStatus.Initializing The specified instance status does not support this operation. The specified instance cannot be released at this time. Try again later.
403 InvalidOperation.DeletionProtection %s The operation is invalid. Disable release protection for the instance first.
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 OperationDenied.SystemInstanceNotSupport The system instance does not support the %s operation because %s.
404 InvalidInstanceId.NotFound The specified InstanceId does not exist. The specified instanceId is invalid.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.