在 AWS 状态语言中组合“InputPath”和“Parameters”

Combining `InputPath` and `Parameters` in AWS States Language

AWS States Language specification 描述了 InputPathParameters 字段的作用,但没有给出过滤器一起使用的示例。

我的理解是,如果指定,InputPath 字段给出的 JSON 路径将应用于生成有效输入的原始输入。 然后,如果指定,则应用参数字段的值,修改有效输入。

扩展 the example given in the spec,给定以下 Task 状态定义:

"X": {
  "Type": "Task",
  "Resource": "arn:aws:swf:us-east-1:123456789012:task:X",
  "Next": "Y",
  "InputPath": "$.sub",
  "Parameters": {
    "flagged": true,
    "parts": {
      "first.$": "$.vals[0]",
      "last3.$": "$.vals[3:]"
    }
  }
}

然后,给定以下输入:

{
  "flagged": 7,
  "sub" : { 
      "vals": [0, 10, 20, 30, 40, 50]
  }
}

Resource 字段中标识的代码的有效输入为:

{
  "flagged": true,
  "parts": {
    "first": 0,
    "last3": [30, 40, 50]
  }
}

我的解释正确吗?

完全正确。 Parameters 是一个 Payload Template 创建来重塑 输入 数据以满足任务的格式期望,而 ResultSelector 做同样的事情但是 输出数据。

The value of "Parameters" MUST be a Payload Template which is a JSON object, whose input is the result of applying the InputPath to the raw input. If the "Parameters" field is provided, its payload, after the extraction and embedding, becomes the effective input.

此外,有时规格可能有点难以阅读,可视化图表可能会有所帮助