ALIYUN::OOS::Execution

ALIYUN::OOS::Execution类型用于启动一个执行。

语法

{
  "Type": "ALIYUN::OOS::Execution",
  "Properties": {
    "ResourceOptions": Map,
    "Parameters": Map,
    "Tags": Map,
    "TemplateName": String,
    "ParentExecutionId": String,
    "SafetyCheck": String,
    "Mode": String,
    "TemplateVersion": String,
    "ResourceGroupId": String,
    "LoopMode": String,
    "Description": String,
    "TemplateContent": String,
    "TemplateURL": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ResourceOptions

Map

ROS使用的资源选项。

更多信息,请参见ResourceOptions属性

Parameters

Map

由参数集合组成的JSON字符串。

示例值:{"Status": "Running"}

默认值:{}。

Tags

Map

标签,由键值对组成。例如:{“k1”:”v1”, ”k2”:”v2”}。

最多支持20个标签。

TemplateName

String

模板名称。

最长为200个字符,不能以ALIYUN、ACS、ALIBABA开头。可包含英文字母、数字、短划线(-)和下划线(_)。

ParentExecutionId

String

父执行ID。

SafetyCheck

String

安全检查模式。

取值:

  • Skip:表示客户了解风险,无需确认即可执行任何Action,无论什么风险等级。当Mode取值为Automatic时有效。

  • ConfirmEveryHighRiskAction(默认值):要求客户确认每一个高风险的Action。客户通过调用NotifyExecution接口进行确认或取消。

Mode

String

执行模式。

取值:

  • Debug

  • Automatic(默认值)

TemplateVersion

String

版本号。

如果不填默认为最新的版本号。

ResourceGroupId

String

资源组ID。

LoopMode

String

循环模式。

Description

String

要给执行添加的描述信息。

TemplateContent

String

模板内容。

JSON 或 YAML 格式(同 CreateTemplate API 请求参数中的 Content 字段)。用户传入此字段可直接执行 TemplateContent 中的任务,而无需提前创建模板再创建执行任务(当用户选择已有的 Template 创建执行任务时不需传入此字段)。

TemplateURL

String

阿里云对象存储 OSS 中存放 OOS 模板内容的 URL(只支持公共读的 URL)。

用户传入此字段可直接根据行 TemplateURL 中存储的模板内容创建执行任务,无需提前创建模板再创建执行任务(当用户选择已有的 Template 创建执行任务时不需传入此字段)。

ResourceOptions语法

"ResourceOptions": {
  "SuccessStatuses": List,
  "Timeout": Number,
  "CancelOnDelete": Boolean,
  "FailureStatuses": List
}

ResourceOptions属性

属性名称

类型

必须

允许更新

描述

约束

SuccessStatuses

List

ROS使用该属性判断资源是否创建成功。

取值:

  • Started

  • Queued

  • Running

  • Waiting

  • Success(默认值)

  • Failed

  • Cancelled

如果Execution的状态在FailureStatuses中,则判定为失败。如果Execution的状态在SuccessStatuses中,则判定为成功。如果上述条件不符合,则一直等待,直到超时(Timeout)。

Timeout

Number

超时时间。

单位:秒。

默认值:1800。

CancelOnDelete

Boolean

删除资源时,如果执行未完成是否取消执行。

取值:

  • true:取消执行。

  • false(默认值):不取消执行。

FailureStatuses

List

ROS使用该属性判断资源是否创建失败。FailureStatuses优先级高于SuccessStatuses。

取值:

  • Started

  • Queued

  • Running

  • Waiting

  • Success

  • Failed

  • Cancelled

默认值:["Failed", "Cancelled"]

返回值

Fn::GetAtt

  • Status:执行状态。

  • WindowsCurlCli:为Windows提供curl CLI命令前缀,可用于发出处理完成或失败的信号。更多信息,请参见NotifyExecution

  • PowerShellCurlCli:为PowerShell提供curl CLI命令前缀,可用于发出信号处理完成或失败。

  • Outputs:执行输出结果。

  • ExecutionId:执行的唯一标识。

  • CurlCli:curl命令。

  • StatusMessage:状态信息。

  • Counters:执行数。

示例

YAML

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  TemplateName:
    Type: String
    Description: Template name. Content is limited to letters, numbers, underlined, underline, the length of 200 characters, and can not begin to ALIYUN, ACS, ALIBABA.
    Label: Template Name
    ConstraintDescription: '[2, 128] English or Chinese characters'
    MinLength: 2
    MaxLength: 128
    Default: mytest
Resources:
  Execution:
    Type: ALIYUN::OOS::Execution
    Properties:
      Parameters: {}
      TemplateName:
        Ref: TemplateName
      ResourceOptions:
        SuccessStatuses:
          - Running
          - Success
          - Queued
          - Waiting
        CancelOnDelete: true
Outputs:
  Status:
    Description: Execution status.
    Value:
      Fn::GetAtt:
        - Execution
        - Status
  WindowsCurlCli:
    Description: 'Convenience attribute, provides curl CLI command prefix for Windows, which can be used to notify oos execution instead of OOS API NotifyExecution. You can notify approve to oos execution by adding --data-binary "{\"data\": {\"NotifyType\": \"Approve\"}}" You can also notify execution via ROS API SignalResource. API parameters Status and UniqueId are ignored. Use API parameter Data to pass data.'
    Value:
      Fn::GetAtt:
        - Execution
        - WindowsCurlCli
  PowerShellCurlCli:
    Description: 'Convenience attribute, provides curl CLI command prefix for PowerShell, which can be used to notify oos execution instead of OOS API NotifyExecution. You can notify approve to oos execution by adding -Body ''{"data": {"NotifyType": "Approve"}}'' You can also notify execution via ROS API SignalResource. API parameters Status and UniqueId are ignored. Use API parameter Data to pass data.'
    Value:
      Fn::GetAtt:
        - Execution
        - PowerShellCurlCli
  Outputs:
    Description: Execution output.
    Value:
      Fn::GetAtt:
        - Execution
        - Outputs
  ExecutionId:
    Description: Execution ID.
    Value:
      Fn::GetAtt:
        - Execution
        - ExecutionId
  CurlCli:
    Description: 'Convenience attribute, provides curl CLI command prefix, which can be used to notify oos execution instead of OOS API NotifyExecution. You can notify approve to oos execution by adding --data-binary ''{"data": {"NotifyType": "Approve"}}''  You can also notify execution via ROS API SignalResource. API parameters Status and UniqueId are ignored. Use API parameter Data to pass data.'
    Value:
      Fn::GetAtt:
        - Execution
        - CurlCli
  StatusMessage:
    Description: Execution status information.
    Value:
      Fn::GetAtt:
        - Execution
        - StatusMessage
  Counters:
    Description: 'Task statistics: FailedTasks, SuccessTasks, TotalTasks.'
    Value:
      Fn::GetAtt:
        - Execution
        - Counters

JSON

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "TemplateName": {
      "Type": "String",
      "Description": "Template name. Content is limited to letters, numbers, underlined, underline, the length of 200 characters, and can not begin to ALIYUN, ACS, ALIBABA.",
      "Label": "Template Name",
      "ConstraintDescription": "[2, 128] English or Chinese characters",
      "MinLength": 2,
      "MaxLength": 128,
      "Default": "mytest"
    }
  },
  "Resources": {
    "Execution": {
      "Type": "ALIYUN::OOS::Execution",
      "Properties": {
        "Parameters": {
        },
        "TemplateName": {
          "Ref": "TemplateName"
        },
        "ResourceOptions": {
          "SuccessStatuses": [
            "Running",
            "Success",
            "Queued",
            "Waiting"
          ],
          "CancelOnDelete": true
        }
      }
    }
  },
  "Outputs": {
    "Status": {
      "Description": "Execution status.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "Status"
        ]
      }
    },
    "WindowsCurlCli": {
      "Description": "Convenience attribute, provides curl CLI command prefix for Windows, which can be used to notify oos execution instead of OOS API NotifyExecution. You can notify approve to oos execution by adding --data-binary \"{\\\"data\\\": {\\\"NotifyType\\\": \\\"Approve\\\"}}\" You can also notify execution via ROS API SignalResource. API parameters Status and UniqueId are ignored. Use API parameter Data to pass data.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "WindowsCurlCli"
        ]
      }
    },
    "PowerShellCurlCli": {
      "Description": "Convenience attribute, provides curl CLI command prefix for PowerShell, which can be used to notify oos execution instead of OOS API NotifyExecution. You can notify approve to oos execution by adding -Body '{\"data\": {\"NotifyType\": \"Approve\"}}' You can also notify execution via ROS API SignalResource. API parameters Status and UniqueId are ignored. Use API parameter Data to pass data.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "PowerShellCurlCli"
        ]
      }
    },
    "Outputs": {
      "Description": "Execution output.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "Outputs"
        ]
      }
    },
    "ExecutionId": {
      "Description": "Execution ID.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "ExecutionId"
        ]
      }
    },
    "CurlCli": {
      "Description": "Convenience attribute, provides curl CLI command prefix, which can be used to notify oos execution instead of OOS API NotifyExecution. You can notify approve to oos execution by adding --data-binary '{\"data\": {\"NotifyType\": \"Approve\"}}'  You can also notify execution via ROS API SignalResource. API parameters Status and UniqueId are ignored. Use API parameter Data to pass data.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "CurlCli"
        ]
      }
    },
    "StatusMessage": {
      "Description": "Execution status information.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "StatusMessage"
        ]
      }
    },
    "Counters": {
      "Description": "Task statistics: FailedTasks, SuccessTasks, TotalTasks.",
      "Value": {
        "Fn::GetAtt": [
          "Execution",
          "Counters"
        ]
      }
    }
  }
}