Stops one or more ECS instances. You can specify the stop method, stop mode, and batch operation mode.
Operation description
This is an asynchronous operation. After a successful call, the instance enters the Stopping state. 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, it becomes unavailable. Make sure that stopping the instance does not affect your business. 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 calls.
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 IDs. Array length: 1 to 100. |
i-bp67acfmxazb4p**** |
|
string |
No |
The instance ID. |
i-bp67acfmxazb4p**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
1C488B66-B819-4D14-8711-C4EAAA13AC01 |
| 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 returned for the instance. A return value of 200 indicates that the operation was successful. For more information, see the "Error codes" section of this topic. |
200 |
| Message |
string |
The error message returned for the instance. The return value |
success |
| InstanceId |
string |
The ID of the instance. |
i-bp67acfmxazb4p**** |
| CurrentStatus |
string |
The current status of the instance. |
Stopping |
| PreviousStatus |
string |
The status of the instance before the operation was called. |
Running |
Examples
Success response
JSON format
{
"RequestId": "1C488B66-B819-4D14-8711-C4EAAA13AC01",
"InstanceResponses": {
"InstanceResponse": [
{
"Code": "200",
"Message": "success",
"InstanceId": "i-bp67acfmxazb4p****",
"CurrentStatus": "Stopping",
"PreviousStatus": "Running"
}
]
}
}
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. | |
| 400 | DRYRUN.SUCCESS | This request is a dryrun request with successful result. | The request is checked and determined as valid. |
| 400 | InvalidParameter.Encrypted.KmsNotEnable | Failed to perform this operation because KMS is not activated. | You need to activate KMS key escrow service. |
| 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. | |
| 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 not found, %s. | The associated KMS encryption key cannot be found. Verify that the KMS encryption key is valid. |
| 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. | |
| 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. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.