Step Function:数据不会传递给下一个 Lambda 函数的事件

Step Function: Data is not passed to next Lambda function's event

假设我有一个非常简单的 lambda 函数

exports.handler = (event,ctx,callback) => {
    console.log(event);
    callback(null,{iteration:1})
};

将在具有此定义的 AWS Step Function 的 Step 机器中使用

{
  "Comment": "A Hello World example of the Amazon States Language using Pass states",
  "StartAt": "Invoke Lambda function",
  "States": {
    "Invoke Lambda function": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "arn:aws:lambda:ap-southeast-1:614275xxxxxx:function:sample-state-machine:$LATEST"
      },
      "Next": "Invoke Lambda function 2"
    },
    "Invoke Lambda function 2": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": "arn:aws:lambda:ap-southeast-1:614275xxxxxx:function:sample-state-machine:$LATEST"
      },
      "End": true
    }
  }
}

然而,cloudwatch 日志显示事件对象中没有任何数据! 有什么很明显的东西我错过了吗?

澄清一下:

将您的状态机更改为

{
  "Comment": "A Hello World example of the Amazon States Language using Pass states",
  "StartAt": "Invoke Lambda function",
  "States": {
    "Invoke Lambda function": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:ap-southeast-1:614275xxxxxx:function:sample-state-machine",
      "Next": "Invoke Lambda function 2"
    },
    "Invoke Lambda function 2": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:ap-southeast-1:614275xxxxxx:function:sample-state-machine",
      "End": true
    }
  }
}

根据documentation,您需要直接将 ARN 设置为资源,而不是使用 arn 作为参数调用 lambda 资源。