ffchih
ffchih

Reputation: 7

aws step functions pass data from lambda to lambda

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

Upvotes: 0

Views: 748

Answers (1)

jellycsc
jellycsc

Reputation: 12259

Try this

{
  "Comment": "commen test",
  "StartAt": "FunctionOne",
  "States": {
    "FunctionOne": {
      "Type": "Task",
      "Resource": "<arn FunctionOne>",
      "Next": "FunctionTwo"
    },
    "FunctionTwo": {
      "Type": "Task",
      "Resource": "<arn FunctionTwo>",
      "End": true
    }
  }
}

Upvotes: 1

Related Questions