【发布时间】:2021-07-02 02:40:34
【问题描述】:
我正在尝试在状态机中使用 Map 任务。设计很简单——我有一个 lambda 函数,可以生成 Map 状态使用的列表。 Map 任务中的每个任务都应该可以访问列表的属性。
现在我观察到只有第一个任务“ETL”将每个列表元素作为输入,而不是第二个任务“WELL CALC”。
我的 Step Machine 失败了
{
"error": "States.Runtime",
"cause": "An error occurred while executing the state 'WELL CALC' (entered at the event id #15). The JSONPath '$.basinName' specified for the field 'basin.$' could not be found in the input '{}'"
}
上述错误为真,ETL lambda 任务的结果返回一个空对象。有没有办法可以将 Map 迭代的“当前项”作为输入传递给所有任务?
这是我的状态机定义:
{
"StartAt": "Generate Basin List",
"States": {
"Generate Basin List": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:451713003466:function:StepFunctionsSample-HelloLam-CheckStockPriceLambda-15TO7SRHAQYQV",
"Next": "Process Basins"
},
"Process Basins": {
"Type": "Map",
"ItemsPath": "$.BasinList",
"End": true,
"Iterator": {
"StartAt": "ETL",
"States": {
"ETL": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:451713003466:function:StepFunctionsSample-HelloLambda0b4d-BuyStockLambda-1WW8B8JQSZ0SY",
"Next": "WELL CALC"
},
"WELL CALC": {
"Type": "Task",
"End": true,
"Parameters": {
"basin.$":"$.basinName",
"phases.$":"$.phases"
},
"Resource": "arn:aws:lambda:us-east-1:451713003466:function:StepFunctionsSample-HelloLambda0b4-SellStockLambda-15I8EE3RWDMS5"
}
}
}
}
}
}
这是“生成盆地列表”lambda:
exports.lambdaHandler = async (event, context) => {
return {
"BasinList": [
{
"basinName": "ARDMORE_AND_MARIETTA_BASINS",
"phases": "1,4,5,8,9,10,13"
}
]
}
};
【问题讨论】:
标签: amazon-web-services aws-step-functions