DescribeInstanceStatus

更新时间:
复制 MD 格式

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 in a specific region based on the instance ID. Sample request:

"RegionID": "cn-hangzhou",
"InstancesID": ["i-bp1f7c1zqp999zvp****", "i-bp1dqjv36biueg61****"]

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:DescribeInstanceStatus

list

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

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

cn-hangzhou

ZoneId

string

No

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

cn-hangzhou-d

ClusterId

string

No

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****

PageNumber

integer

No

The page number.

Pages start from page 1.

Default value: 1.

1

PageSize

integer

No

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

Default value: 10.

10

InstanceId

array

No

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

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

i-bp1j4i2jdf3owlhe****

string

No

The ID of the ECS instance.

i-bp1j4i2jdf3owlhe****

Response elements

Element

Type

Description

Example

object

PageSize

integer

The number of entries per page.

1

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

PageNumber

integer

The page number.

1

TotalCount

integer

The total number of instances.

58

InstanceStatuses

object

InstanceStatus

array<object>

The IDs and status of the ECS instances.

object

Status

string

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

InstanceId

string

The ID of the instance.

i-bp1j4i2jdf3owlhe****

Examples

Success response

JSON format

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

Error response

JSON format

{
"RequestId": "6EF60BEC-0242-43AF-BB20-270359FB54A7",
"TotalCount": 2,
"PageNumber": 1,
"PageSize": 10,
"InstanceStatuses": {
    "InstanceStatus": [{
        "InstanceId": "i-instance1",
            "Status": "Running"
        },
        {
            "InstanceId": "i-ae4r89pp",
            "Status": "Stopped"
        }]
    }
}

Error codes

HTTP status code

Error code

Error message

Description

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.
404 InvalidZoneId.NotFound The ZoneId provided does not exist in our records.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.