Search code examples
amazon-web-servicesaws-step-functions

pass output of step function one trigger to next trigger in AWS


I am trying to pass output of 1st trigger as input to my lambda function. After code run i am not able to see my lambda function is called. Although I seen that Input of 2nd step function is taken as string as it is. It is not passing actual value. please see below image. Input & Output for 2nd trigger

enter image description here

    {
  "Comment": "A description of my state machine",
  "StartAt": "Pass",
  "States": {
    "Pass": {
      "Type": "Pass",
      "Result": {
        "method": "GET",
        "body": "SELECT * from TestTable"
      },
      "ResultPath": "$.latest",
      "OutputPath": "$.latest",
      "Next": "NextPass"
    },
    "NextPass": {
       "Type": "Task",
      "Resource": "arn:aws:lambda:<location>:<key>:function:<function-Name>",
      "Parameters": {
        "method": "$.latest.method",
        "body": "$.latest.body"
      },
      "End": true
    }
  }
}

Solution

  • To access the data from the input, you need to add ".$" to the end of the Parameter names. This tells Step Functions that you're reading from a JSON path.

    So your code should look like the following snippet below:

    "Parameters": {
      "method.$": "$.latest.method",
      "body.$": "$.latest.body"
    }
    

    Hope that helps!