qkhanhpro
qkhanhpro

Reputation: 5220

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

Suppose I have a very simple lambda function

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

That will be used in a AWS Step Function's Step machine with this definition

{
  "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
    }
  }
}

However the cloudwatch log show no data inside the event object! Is there something very obvious that I missed?

For clarification:

Upvotes: 0

Views: 1103

Answers (1)

Rubbal
Rubbal

Reputation: 809

Change your state machine to

{
  "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
    }
  }
}

According to documentation you need to set the ARN directly as the resource instead of calling lambda resource with arn as a parameter.

Upvotes: 2

Related Questions