You can call this operation to delete a stack and all of its resources.


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
Action String Yes DeleteStack

The operation that you want to perform. Set the value to DeleteStack.

RegionId String Yes cn-hangzhou

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

StackId String Yes 4a6c9851-3b0f-4f5f-b4ca-a14bf691****

The ID of the stack.

RetainAllResources Boolean No false

Specifies whether to retain the resources in the stack.

RetainResources.N RepeatList No WebServer

The list of resources to retain.

RamRoleName String No test-role

The name of the RAM role. ROS assumes the specified RAM role to create the stack and call API operations by using the credentials of the role.

All operations will be performed under this role. If a RAM user is authorized to perform operations on the stack but does not have the permission to use the role, ROS still uses the role and grants the role the least privilege.

If you do not specify this parameter, ROS does not use the role previously associated with the stack. If you want to use a role, you must specify it in this parameter. If no roles are available, ROS uses the temporary credentials generated from the credentials of your account.

The RAM role name can be up to 64 characters in length.

Response parameters

Parameter Type Example Description
RequestId String B288A0BE-D927-4888-B0F7-B35EF84B6E6F

The ID of the request.


Sample requests

http(s):// Action=DeleteStack
&<Common request parameters>

Sample success responses

XML format


JSON format

  "RequestId": "B288A0BE-D927-4888-B0F7-B35EF84B6E6F"

Error codes

For a list of error codes, visit the API Error Center.

For more information about errors common to all operations, see Common error codes.

HTTP status code

Error code

Error message




Fail to delete stack {ID}, as deletion protection is enabled.

The error message returned because deletion protection prevented the stack from being deleted. ID indicates the stack ID.



The Stack ({name}) could not be found.

The error message returned because the specified stack does not exist. name indicates the stack name or ID.



Stack {name} already has an action ({action}) in progress.

The error message returned because the specified stack has a change operation in progress. name indicates the stack name or ID, and action indicates the change operation.