语法
{
  "Type": "ALIYUN::ROS::WaitConditionHandle",
  "Properties": {
    "Mode": String,
    "Count": Integer
  }
}
属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Mode | String | 否 | 是 | 控制旧信号在资源更新前如何删除。 |  | 
| Count | Integer | 否 | 是 | Mode取值为Full时,ID为整数且大于Count的旧信号在资源更新前会被删除。 | 默认值为-1。 当满足以下2个条件时,该属性生效:  如果该属性生效,则ID>Count的旧信号将在更新前删除。如果存在非整数ID的旧信号,则资源更新失败。 
 说明 在需要通过更新资源栈进行弹性扩容或缩容的场景下,推荐设置该值,并与ALIYUN::ROS::WaitCondition的Count属性取值相同。 | 
返回值
Fn::GetAtt
- CurlCli:该资源产生的curl命令。通过该命令发送自定义数据执行的结果或者状态到资源编排服务。 
- WindowsCurlCli:为Windows提供curl CLI命令前缀,可用于发送处理完成或失败的信号。由于Windows不支持curl命令,您需要先安装curl.exe并将其添加到PATH中。您可以通过添加- -d "{\"status\": \" SUCCESS \"}表示成功、添加- -d "{\"status\": \" FAILURE \"}表示失败。
 
- PowerShellCurlCli:为PowerShell提供curl CLI命令前缀,可用于发送处理完成或失败的信号。由于此cmdlet是在PowerShell 3.0中引入的,所以要确保PowerShell的版本满足此约束,PowerShell的版本可以通过- $PSVersionTable.PSVersion显示。您可以通过添加- -Body '{"status": " SUCCESS "}表示成功、添加- -Body '{"status": " FAILURE "}表示失败。
 
- Headers:HTTP POST请求头,可用于在程序中发送处理完成或失败的信号。 
- URL:HTTP POST请求地址,可用于在程序中发送处理完成或失败的信号。 
说明 - CurlCli、WindowsCurlCli、PowerShellCurlCli的请求体中均可通过设置ID字段(字符串)明确指定信号ID。 - 例如:- -d "{\"status\": \" SUCCESS \", \"id\": \"test\"}。
 - 相同ID的信号会被当作同一信号,后面收到的信号会覆盖前面收到的。 - 如果没有指定ID,ROS会使用整数作为信号ID,这个整数=已有信号的数量+1。 
- CurlCli、WindowsCurlCli、PowerShellCurlCli的请求体中均可通过设置- reason字段(字符串)设置信号成功或失败原因,这个原因会出现在ROS资源栈事件(信号通知类型)当中。
 - 例如:- -d "{\"status\": \" SUCCESS \", \"reason\": \"nginx is installed successfully.\"}"。
 - 指定了- reason字段之后,这个请求的内容就会出现在资源栈事件(信号通知类型)当中。
 
- CurlCli、WindowsCurlCli、PowerShellCurlCli的请求体中均可通过设置了- data字段(字符串)设置信号关联的数据,这个数据可以通过ALIYUN::ROS::WaitCondition的输出属性Data、ErrorData、JoinedErrorData获取。
 - 例如:- -d "{\"id\" : \"ssh_pub_key\", \"data\" : \"$pub_key\"}"。
 
- 通过- status字段可以指定信号类型,包括- SUCCESS、- FAILURE、- WARNING。信号类型与资源操作结果的关系如下:(优先级从高到低)
 
 示例
- YAML格式
 - ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  InstanceId:
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
Resources:
  InstallNginx:
    Type: 'ALIYUN::ECS::RunCommand'
    Properties:
      Type: RunShellScript
      CommandContent:
        Fn::Sub: |
            #!/bin/sh
            yum install -y nginx
            systemctl restart nginx
            if [[ $? -eq 0 ]];
            then
            ${InstallNginxWaitConditionHandle.CurlCli} --data-binary "{\"status\": \"SUCCESS\", \"data\": \"Nginx is installed successfully.\"}"
            else
            ${InstallNginxWaitConditionHandle.CurlCli} --data-binary "{\"status\": \"FAILURE\", \"reason\": \"Failed to install and start nginx.\"}"
            fi
      Name: InstallNginxScript
      InstanceIds:
        - Ref:
            InstanceId
      Timeout: 60
  InstallNginxWaitConditionHandle:
    Type: 'ALIYUN::ROS::WaitConditionHandle'
  InstallNginxWaitCondition:
    Type: 'ALIYUN::ROS::WaitCondition'
    Properties:
      Handle:
        Ref: InstallNginxWaitConditionHandle
      Timeout: 60
Outputs:
  InstallNginxData:
    Description: Received the data sent by the first ecs, JSON serialized dict containing
      data associated with wait condition signals sent to the handle.
    Value:
      Fn::GetAtt:
      - InstallNginxWaitCondition
      - Data
 
- JSON格式
 - {
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "InstanceId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceId"
    }
  },
  "Resources": {
    "InstallNginx": {
      "Type": "ALIYUN::ECS::RunCommand",
      "Properties": {
        "Type": "RunShellScript",
        "CommandContent": {
          "Fn::Sub": "#!/bin/sh\nyum install -y nginx\nsystemctl restart nginx\nif [[ $? -eq 0 ]];\nthen\n${InstallNginxWaitConditionHandle.CurlCli} --data-binary \"{\\\"status\\\": \\\"SUCCESS\\\", \\\"data\\\": \\\"Nginx is installed successfully.\\\"}\"\nelse\n${InstallNginxWaitConditionHandle.CurlCli} --data-binary \"{\\\"status\\\": \\\"FAILURE\\\", \\\"reason\\\": \\\"Failed to install and start nginx.\\\"}\"\nfi\n"
        },
        "Name": "InstallNginxScript",
        "InstanceIds": [
          {
            "Ref": "InstanceId"
          }
        ],
        "Timeout": 60
      }
    },
    "InstallNginxWaitConditionHandle": {
      "Type": "ALIYUN::ROS::WaitConditionHandle"
    },
    "InstallNginxWaitCondition": {
      "Type": "ALIYUN::ROS::WaitCondition",
      "Properties": {
        "Handle": {
          "Ref": "InstallNginxWaitConditionHandle"
        },
        "Timeout": 60
      }
    }
  },
  "Outputs": {
    "InstallNginxData": {
      "Description": "Received the data sent by the first ecs, JSON serialized dict containing data associated with wait condition signals sent to the handle.",
      "Value": {
        "Fn::GetAtt": [
          "InstallNginxWaitCondition",
          "Data"
        ]
      }
    }
  }
}
 
更多示例,请参见JSON示例和YAML示例。