All Products
Search
Document Center

CloudOps Orchestration Service:ACS::WaitFor

Last Updated:Jun 16, 2026

Purpose

The ACS::WaitFor action waits for a resource to enter an expected state. It repeatedly calls a cloud service API operation to query the resource status until the status matches the expected value. For example, after you call the RunInstances operation of Elastic Compute Service (ECS) to create an ECS instance, you can perform the ACS::WaitFor action to wait until the instance enters the Running state.

Syntax

Tasks:
  - Name: waitForTaskExample
    Action: ACS::WaitFor
    Properties: 
      # The following attributes are the same as those of the ACS::ExecuteAPI action. For more information, see the syntax description of the ACS::ExecuteAPI action. 
      Service: ECS
      API: DescribeInstances
      Parameters: 
        InstanceId: i-12345678abcedfg
      # The following attributes are the unique attributes of the ACS::WaitFor action.
      PropertySelector: "jq selector" # Required. The selector for selecting the API result to wait for. In this example, the jq selector is used. For more information, see the description of the ValueSelector attribute in the ACS::ExecuteAPI action.
      StopRetryValues: # Optional. The values based on which the system stops the wait task and API call retries. For example, if you set this attribute to Stopped, the system stops the wait task when the Stopped value is detected. 
        - status1
      DesiredValues: # The expected values. If the value selected by the PropertySelector attribute matches one of the specified values, the wait task is successful. If the value selected by the PropertySelector attribute does not match any of the specified values, the wait task times out and fails. You must specify one of the DesiredValues and NotDesiredValues attributes. 
        - value1
        - value2
      NotDesiredValues: # The values that are not expected. If the value selected by the PropertySelector attribute does not match any of the specified values, the wait task is successful. If the value selected by the PropertySelector attribute matches one of the specified values, the wait task times out and fails. You must specify one of the DesiredValues and NotDesiredValues attributes. 
        - value3
        - value4
    Retries: # Optional. The maximum number of retries. The value must be a positive integer, such as 5. Valid values: 0 to 300. Default value: 10. 
    DelayType: # The retry interval type. Valid values: Exponential, Constant, and Linear. Default value: Exponential. The retry interval of the Exponential type is calculated by using the following formula: 2 ^ Number of retries. The retry interval of the Constant type is specified by the Delay attribute. The retry interval of the Linear type is calculated by using the following formula: Value of the Delay attribute + Value of the BackOff attribute × Number of retries. 
    Delay: # The retry interval. The value must be a positive integer, such as 10. A value of 10 indicates that the retry interval is 10 seconds. Valid values: 1 to 3600. Default value: 2. This parameter is required if the DelayType attribute is set to Constant or Linear. 
    BackOff: # The retry interval compensation. The value must be a positive integer. Valid values: 1 to 3600. Default value: 2. This parameter is required if the DelayType attribute is set to Linear. 
    MaxRetryInterval: # The maximum retry interval. The value must be a positive integer. Valid values: 1 to 1800. Default value: 1800. Unit: seconds. 
    Outputs: # The output parameters of the wait task. If the NotDesiredValues or DesiredValues condition is met, the wait task is successful, and the output parameters are returned. 
      ValueSelector: # The jq selector for selecting the data to return. The jq selector extracts information from the JSON data returned by the API operation. For more information about the jq syntax, visit https://stedolan.github.io/jq.
      Type: String/Boolean/List(Array)/Number/Object
{
  "Tasks": [
    {
      "Name": "waitForTaskExample",
      "Action": "ACS::WaitFor",
      "Properties": {
        "Service": "ECS",
        "API": "DescribeInstances",
        "Parameters": {
          "InstanceId": "i-12345678abcedfg"
        },
        "PropertySelector": "jq selector",
        "StopRetryValues": [
          "status1"
        ],
        "DesiredValues": [
          "value1",
          "value2"
        ],
        "NotDesiredValues": [
          "value3",
          "value4"
        ]
      },
      "Retries": "# Optional. The maximum number of retries. The value must be a positive integer, such as 5. Valid values: 0 to 300. Default value: 10.",
      "DelayType": "# The retry interval type. Valid values: Exponential, Constant, and Linear. Default value: Exponential. The retry interval of the Exponential type is calculated by using the following formula: 2 ^ Number of retries. The retry interval of the Constant type is specified by the Delay attribute. The retry interval of the Linear type is calculated by using the following formula: Value of the Delay attribute + Value of the BackOff attribute × Number of retries.",
      "Delay": "# The retry interval. The value must be a positive integer, such as 10. A value of 10 indicates that the retry interval is 10 seconds. Valid values: 1 to 3600. Default value: 2. This parameter is required if the DelayType attribute is set to Constant or Linear.",
      "BackOff": "# The retry interval compensation. The value must be a positive integer. Valid values: 1 to 3600. Default value: 2. This parameter is required if the DelayType attribute is set to Linear.",
      "MaxRetryInterval": "# The maximum retry interval. The value must be a positive integer. Valid values: 1 to 1800. Default value: 1800. Unit: seconds.",
      "Outputs": {
        "ValueSelector": "# The jq selector for selecting the data to return. The jq selector extracts information from the JSON data returned by the API operation. For more information about the jq syntax, visit https://stedolan.github.io/jq.",
        "Type": "String/Boolean/List(Array)/Number/Object"
      }
    }
  ]
}

Examples

The following template starts an ECS instance and waits for it to enter the Running state.

---
FormatVersion: OOS-2019-06-01
Parameters:
  InstanceId:
    Description: the instance id that you will start.
    Type: String
Tasks:
- Name: startInstance
  Action: ACS::ExecuteAPI
  Description: start instance with specified parameters
  Properties:
    Service: ECS
    API: StartInstance
    Parameters:
      InstanceId: '{{ InstanceId }}'
- Name: untilInstanceReady
  Action: ACS::WaitFor
  Description: describe instances with specified parameters
  MaxRetryInterval: 900
  Properties:
    Service: ECS
    API: DescribeInstances
    Parameters:
      InstanceIds:
      - '{{ InstanceId }}'
    PropertySelector: Instances.Instance[].Status
    DesiredValues:
    - Running
{
    "FormatVersion": "OOS-2019-06-01",
    "Parameters": {
        "InstanceId": {
            "Description": "the instance id that you will start.",
            "Type": "String"
        }
    },
    "Tasks": [
        {
            "Name": "startInstance",
            "Action": "ACS::ExecuteAPI",
            "Description": "start instance with specified parameters",
            "Properties": {
                "Service": "ECS",
                "API": "StartInstance",
                "Parameters": {
                    "InstanceId": "{{ InstanceId }}"
                }
            }
        },
        {
            "Name": "untilInstanceReady",
            "Action": "ACS::WaitFor",
            "Description": "describe instances with specified parameters",
            "MaxRetryInterval": 900,
            "Properties": {
                "Service": "ECS",
                "API": "DescribeInstances",
                "Parameters": {
                    "InstanceIds": [ "{{ InstanceId }}"]
                },
                "PropertySelector": "Instances.Instance[].Status",
                "DesiredValues": [ "Running" ]
            }
        }
    ]
}