Stops Elastic Compute Service (ECS) instances. After the operation is called, the state of the instances changes to Stopping and then to Stopped.
Operation description
- If the response contains
{"OperationLocks": {"LockReason" : "security"}}
for an instance, the instance is locked for security reasons. No operations are allowed on the instance. - After you enable the economical mode for a pay-as-you-go instance that resided in a virtual private cloud (VPC), you can set
StoppedMode
to KeepCharging. Then, the pay-as-you-go instance continues to be billed after it is stopped. The instance type resources and public IP address are reserved for the instance. - Batch operations are supported. You can use
BatchOptimization
to specify the batch operation mode.
Debugging
Authorization information
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
DryRun | boolean | No | Specifies whether to perform only a dry run, without performing the actual request. Valid values:
Note
If you set BatchOptimization to SuccessFirst and DryRun to true, only DRYRUN.SUCCESS is returned regardless of whether the request passes the dry run.
Default value: false. | false |
RegionId | string | Yes | The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list. | cn-hangzhou |
ForceStop | boolean | No | Specifies whether to stop the instance in a forceful manner. Valid values:
Default value: false. | false |
StoppedMode | string | No | The stop mode of the pay-as-you-go instance. Valid values:
Default value: If the prerequisites required for enabling economical mode are met and you have enabled the mode in the ECS console, the default value is StopCharging . For more information, see the "Enable economical mode" section in | KeepCharging |
BatchOptimization | string | No | The batch operation mode. Valid values:
Default value: AllTogether. | AllTogether |
InstanceId | array | Yes | The IDs of instances. | |
string | Yes | The ID of instance N. Valid values of N: 1 to 100. | i-bp67acfmxazb4p**** |
Response parameters
Examples
Sample success responses
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.CMKNotEnabled | The CMK needs to be enabled. | The customer master key (CMK) is not enabled when KMSKeyId is specified for an encrypted disk. You can call the DescribeKey operation of KMS to query information about the specified CMK. |
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. |
403 | InvalidInstanceId.NotFound | InstanceId should not be null. | - |
403 | InvalidParameter.TooManyInstanceIds | Instance ids 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. | Your account balance is insufficient. Add funds to your account and try again. |
403 | InstanceNotReady | The specified instance is not ready for use. | The resource is in a state that does not support the current operation. Try again later and check whether the instance state supports the operation. |
404 | InvalidInstanceId.NotFound | %s | The specified instance does not exist. Check whether the InstanceId parameter is valid. |
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. |
404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | The specified instance does not exist. |
409 | InvalidOperation.Conflict | Request was denied due to conflict with a previous request, please try again later. | - |
500 | InternalError | The 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.