All Products
Search
Document Center

Elastic Compute Service:DeleteInstance

Last Updated:Dec 17, 2024

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

Operation description

**

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

  • Precautions

    When you release an instance, manual snapshots of the cloud disks are retained. The settings configured during the creation of the instance determine whether the cloud disks attached to the instance and automatic snapshots are released. Before you release the instance, you can call the DescribeDisks operation to query the parameter settings for the cloud disks attached to the instance and the automatic snapshots.

    • The cloud disks for which DeleteWithInstance is set to false are retained as pay-as-you-go disks after the instance is released. The cloud disks for which DeleteWithInstance is set to true are released along with the instance.
    • If DeleteAutoSnapshot is set to false for a cloud disk attached to the instance, the automatic snapshots of the cloud disk are retained when the instance is released. If DeleteAutoSnapshot is set to true for the cloud disk, the cloud disk is released along with the instance.
Note When you release an instance that is locked for security reasons, the cloud disks attached to the instance are released even if DeleteWithInstance is set to false.

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:DeleteInstancedelete
*Instance
acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The ID of the instance.

i-bp1g6zv0ce8oghu7****
ForcebooleanNo

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

  • true: forcefully releases the instance in the Running (Running) state.
  • false: normally releases the instance. This value take effects 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
DryRunbooleanNo

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

  • true: performs only a dry run. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, service limits, and unavailable ECS resources. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.
  • false (default): performs a dry run and performs the actual request. If the request passes the dry run, the instance is released.
false

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
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.
400InvalidParameterThe input parameter InstanceId is invalid.The specified InstanceId parameter is invalid.
403IncorrectInstanceStatusThe current status of the resource does not support this operation.The resource is in a state that does not support the current operation.
403InstanceLockedForSecurityThe specified operation is denied as your instance is locked for security reasons.-
403ChargeTypeViolationThe operation is not permitted due to charge type of the instance.The operation is not supported while the instance is using the current billing method.
403IncorrectInstanceStatus.InitializingThe specified instance status does not support this operation.The specified instance cannot be released at this time. Try again later.
403IncorrectInstanceStatusThe specified instance is still attached by volumes.The specified instance has data volumes.
403InvalidOperation.DeletionProtection%sThe operation is invalid. Disable release protection for the instance first.
403InvalidOperation.DeletionProtectionThe operation is not allowed due to deletion protection.Instance has release protection turned on, so this operation cannot be performed
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.
404InvalidInstanceId.NotFoundThe specified InstanceId does not exist.The specified instance does not exist.
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.

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

Change history

Change timeSummary of changesOperation
2024-02-01The Error code has changed. The request parameters of the API has changedView Change Details
2023-07-17The Error code has changedView Change Details