All Products
Search
Document Center

Alibaba Cloud CLI:Results polling

Last Updated:Feb 20, 2024

With the APIs of Alibaba Cloud, the results returned by some APIs will change over time. You can poll the results until a value with a specific status is found, at which time polling is stopped and data is returned.

--waiter overview

You can use --waiter to poll results. This option contains the following two sub-fields:

Field Name

Description

expr

Indicates the polled field in the JSON result specified by the jmespath query statement.

to

Indicates the target value of the polled field.

Sample

  • Scenario

    After running the command to create an ECS instance, call DescribeInstances API action to query the details of one or more instances. Given that an instance takes some time to be created, the API will continuously query if the instance is in the running status until the instance is in Running status, at which time the DescribeInstances API action returns the result.

  • Solution

    For Alibaba Cloud CLI poll the instance status, run the following command:

    aliyun ecs DescribeInstances --InstanceIds '["i-12345678912345678123"]' --waiter expr='Instances.Instance[0].Status' to=Running