All Products
Search
Document Center

Elastic Compute Service:DescribeInstanceStatus

更新時間:Dec 23, 2024

Queries the status of one or more Elastic Compute Service (ECS) instances. You can also call this operation to query the list of ECS instances that match the specified filter conditions.

Operation description

For information about the lifecycle states of an ECS instance, see Instance lifecycle.

Sample requests

  • Query the ECS instances and the status of the instances in a specific region. Sample request:
"RegionID": "cn-hangzhou"
  • Query the ECS instances and the status of the instances in a zone of a specific region. Sample request:
      "RegionID": "cn-hangzhou",
      "ZoneID": "cn-hangzhou-a"
  • Query the status of an ECS instance based on the instance ID in a specific region. Sample request:
"RegionID": "cn-hangzhou",
"InstancesID": ["i-bp1f7c1zqp999zvp****", "i-bp1dqjv36biueg61****"]

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:DescribeInstanceStatusget
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

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

cn-hangzhou
ZoneIdstringNo

The zone ID of the instances. You can call the DescribeZones operation to query the most recent zone list.

cn-hangzhou-d
ClusterIdstringNo

The ID of the cluster to which the ECS instances belong.

Note This parameter is deprecated. We recommend that you do not use this parameter.
cls-bp67acfmxazb4p****
PageNumberintegerNo

The page number.

Pages start from page 1.

Default value: 1.

1
PageSizeintegerNo

The number of entries per page. Valid values: 1 to 50.

Default value: 10.

10
InstanceIdarrayNo

The IDs of ECS instances. You can specify 1 to 100 instance IDs.

Example: ["i-bp1j4i2jdf3owlhe****", "i-bp1j4i2jdf3o1234****"].

stringNo

The ID of the ECS instance.

i-bp1j4i2jdf3owlhe****

Response parameters

ParameterTypeDescriptionExample
object
PageSizeinteger

The number of entries per page.

1
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E
PageNumberinteger

The page number.

1
TotalCountinteger

The total number of instances.

58
InstanceStatusesarray<object>

The IDs and status of the ECS instances.

InstanceStatusobject
Statusstring

The status of the instance. Valid values:

  • Pending: The instance is being created.
  • Running: The instance is running.
  • Starting: The instance is being started.
  • Stopping: The instance is being stopped.
  • Stopped: The instance is stopped.
Running
InstanceIdstring

The ID of the instance.

i-bp1j4i2jdf3owlhe****

Examples

Sample success responses

JSONformat

{
  "PageSize": 1,
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "PageNumber": 1,
  "TotalCount": 58,
  "InstanceStatuses": {
    "InstanceStatus": [
      {
        "Status": "Running",
        "InstanceId": "i-bp1j4i2jdf3owlhe****"
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
403InvalidParameter.TooManyInstanceIdsInstance ids cannot be more than 100.-
403Abs.InvalidInstanceIds.MalFormedThe specified instanceIds is not valid.-
404InvalidZoneId.NotFoundThe ZoneId provided does not exist in our records.The specified zone ID does not exist.

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