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.
You can use --waiter to poll results. This option contains the following two sub-field:
|expr||Indicates the polled field in the JSON result specified by the jmespath query statement.|
|to||Indicates the target value of the polled field.|
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.
For Alibaba Cloud CLI poll the instance status, run the following command:
aliyun ecs DescribeInstances --InstanceIds '["i-12345678912345678123"]' --waiter expr='Instances.Instance.Status' to=Running