0

I've been researching on how to pass data from a Lambda to another Lambda in a Step Function and this is what i got. I have this dummy lambda that pass the data name:

exports.lambdaHandler = async (event, context, callback) => {
    const name = 'test';
    callback(null, { name });
}

to another lambda, where i try to get the data in this way, but is not working:

const name = event.name; //this returns undefined

Based on this tutorial, this should be enough but it doesn't work. Can you point me in what direction should i go? Do i have to use the InputPath, ResultPath properties of the states machines?

[Update] This is the State machine definition:

{
  "Comment": "commen test",
  "StartAt": "FunctionOne",
  "States": {
    "FunctionOne": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": <arn FunctionOne>
      },
      "Next": "FunctionTwo"
    },
    "FunctionTwo": {
      "Type": "Task",
      "Resource": "arn:aws:states:::lambda:invoke",
      "Parameters": {
        "FunctionName": <arn FunctionTwo>
      },
      "End": true
    }
  }
}
2
  • Can you post your fsm definition? Commented Jul 27, 2020 at 20:59
  • @jellycsc updated Commented Jul 27, 2020 at 21:04

1 Answer 1

1

Try this

{
  "Comment": "commen test",
  "StartAt": "FunctionOne",
  "States": {
    "FunctionOne": {
      "Type": "Task",
      "Resource": "<arn FunctionOne>",
      "Next": "FunctionTwo"
    },
    "FunctionTwo": {
      "Type": "Task",
      "Resource": "<arn FunctionTwo>",
      "End": true
    }
  }
}
Sign up to request clarification or add additional context in comments.

2 Comments

It worked, thank you! Do you have an explanation for the change you propose? When creating the states I used the "generate snippets" option, and print out the states with that format
You don't need a service integration to call a lambda. Please read this documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.