地图输入来自执行输入的 AWS Step 函数



我正在尝试创建一个具有Map状态的 AWS step 函数,其输入(即要迭代的数组(来自执行输入。一个归约示例 JSON 步骤函数如下所示:

{
"StartAt": "pass",
"States": {
"pass": {
"Type": "Pass",
"Next": "map-sleep"
},
"map-sleep": {
"MaxConcurrency": 5,
"InputPath": "$$.Execution.Input['data']",
"Iterator": {
"StartAt": "wait",
"States": {
"wait": {
"SecondsPath": "$['length']",
"Type": "Wait",
"End": true
}
}
},
"Type": "Map",
"Next": "final-wait"
},
"final-wait": {
"Seconds": 10,
"Type": "Wait",
"End": true
}
}
}

但是,当我尝试创建它时,我遇到了错误:

调用 CreateStateMachine 操作时出错 (InvalidDefinition(:状态机定义无效:"SCHEMA_VALIDATION_FAILED:值必须是有效的 JSONPath。 at/States/map-sleep/InputPath'

我由此推断InputPath是错误的,但我不太明白为什么,或者表达我想要做的事情的正确方式是什么。(此代码是使用 Python Step Functions SDK 生成的,如果有帮助,我可以分享此代码,但我认为将其简化为 JSON 会更容易考虑(。

好吧,我强烈怀疑这不是最佳答案,但看起来通过使用ParametersPass节点与Map节点相结合,您可以获得所需的结果:

"map-sleep-pass": {
"Parameters": {
"items.$": "$$.Execution.Input['data']"
},
"Type": "Pass",
"Next": "map-sleep"
},
"map-sleep": {
"MaxConcurrency": 5,
"InputPath": "$.items",
"Iterator": {
"StartAt": "wait",
"States": {
"wait": {
"SecondsPath": "$['length']",
"Type": "Wait",
"End": true
}
}
},
"Type": "Map",
"Next": "final-wait"
},

最新更新