Stops one or more ECS instances. You can specify different stop methods, stop modes, and batch operation modes.
Operation description
This is an asynchronous operation. Instances are not stopped immediately after a successful call. After a successful call, the instance enters the Stopping state. You can call DescribeInstanceStatus to query the instance status. When the returned status is Stopped, the instance is stopped.
Before you begin
After an instance is stopped, the instance becomes unavailable. Make sure that stopping the instance does not affect your business. You can call StartInstance or StartInstances to start the instance.
Instances that are locked for security reasons cannot be stopped by calling this operation. For more information, see Impacts of resource security locks on API operations.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:StopInstances |
update |
*Instance
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| DryRun |
boolean |
No |
Specifies whether to send a dry run request. Valid values:
Note
If the BatchOptimization parameter is set to
Default value: false. |
false |
| RegionId |
string |
Yes |
The region ID of the instances. You can call DescribeRegions to query the most recent region list. |
cn-hangzhou |
| ForceStop |
boolean |
No |
Specifies whether to forcefully stop the instances. Valid values:
Default value: false. |
false |
| StoppedMode |
string |
No |
The stop mode. Valid values:
Default value: If you enable economical mode for VPC-connected instances and the conditions are met, the default value is |
KeepCharging |
| BatchOptimization |
string |
No |
The batch operation mode. Valid values:
Default value: AllTogether. |
AllTogether |
| InstanceId |
array |
Yes |
The instance ID array. Array length: 1 to 100. |
i-bp67acfmxazb4p**** |
|
string |
No |
The instance ID. |
i-bp67acfmxazb4p**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| InstanceResponses |
object |
||
| InstanceResponse |
array<object> |
The array of InstanceResponse objects that contains the status before and after the operation and the operation result for each instance. |
|
|
object |
|||
| Code |
string |
The error code of the instance operation result. A return value of 200 indicates success. For more information, see the error codes section. |
200 |
| CurrentStatus |
string |
The current status of the instance. |
Stopping |
| InstanceId |
string |
The instance ID. |
i-bp67acfmxazb4p**** |
| Message |
string |
The error message returned for the instance operation. A return value of |
success |
| PreviousStatus |
string |
The status of the instance before the operation. |
Running |
| RequestId |
string |
The request ID. |
1C488B66-B819-4D14-8711-C4EAAA13AC01 |
Examples
Success response
JSON format
{
"InstanceResponses": {
"InstanceResponse": [
{
"Code": "200",
"CurrentStatus": "Stopping",
"InstanceId": "i-bp67acfmxazb4p****",
"Message": "success",
"PreviousStatus": "Running"
}
]
},
"RequestId": "1C488B66-B819-4D14-8711-C4EAAA13AC01"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter.KMSKeyId.CMKNotEnabled | The CMK needs to be added ECS tag | |
| 400 | InvalidParameter.KMSKeyId.KMSUnauthorized | ECS service account have no right to access your KMS. | ECS does not have the permission to access your Key Management Service (KMS). |
| 400 | DRYRUN.SUCCESS | This request is a dryrun request with successful result. | The request is checked and determined as valid. |
| 400 | InvalidParameter.Encrypted.KmsNotEnable | The operation failed because KMS is not activated. Please activate KMS in the KMS console and try again. | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | InvalidInstanceId.NotFound | InstanceId should not be null. | |
| 403 | InvalidParameter.TooManyInstanceIds | Instance ids cannot be more than 100. | InstanceIds cannot be more than 100. |
| 403 | Abs.InvalidInstanceIds.MalFormed | The specified instanceIds is not valid. | The specified InstanceId parameter is invalid. |
| 403 | InstanceLockedForSecurity | %s | |
| 403 | InstanceExpiredOrInArrears | %s | |
| 403 | IncorrectInstanceStatus | %s | The instance is in a state that does not support the current operation. |
| 403 | InvalidInstanceId.NotSupport | %s | |
| 403 | InsufficientBalance | Your account does not have enough balance. | |
| 403 | InstanceNotReady | The specified instance is not ready for use. | |
| 403 | InvalidOperation.KMSKeyIdNotFound | The specified KMSKeyId does not exist. Please verify that the key ID is correct and that the key resides in the current region. | |
| 403 | InvalidOperation.KMSServiceNotOpen | KMS service is currently not open. | The KMS service has not been enabled. |
| 403 | OperationDenied.SystemInstanceNotSupport | The system instance does not support the %s operation because %s. | |
| 403 | OperationDenied.KMSKeyUnauthorized | The operation is denied due to missing KMS key authorization. Please check the KMS key permissions and ensure the key is properly authorized for this operation. | |
| 404 | InvalidInstanceId.NotFound | %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. |
| 503 | LimitedOperation.ServiceUnavailable | The service is currently unavailable. Please try again later. | The service is currently unavailable. Please try again later. |
| 409 | InvalidOperation.Conflict | Request was denied due to conflict with a previous request, please try again later. | This operation is not allowed due to a task conflict. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.