In this case, I use the Stepfunctions as my API endpoint.
There are 2 lambdas need to be run base one the first lambda’s return code in the stepfunctions.
All the 3 lambdas need to get the http request body data from statemachine’s state input.
So, I considered if anything can save the state input at first, then the other lambda can use it as inputPath,
actually, no thus solution after read aws document about stepfunction.
But I found another way can pass the state input through the lambda one by one.

my case Link to heading

1-stepfunction

my solution Link to heading

  • use ResultPath to include the state input with result at the first lambda.
1
"ResultPath": "$.dispatcher_result",
  • use InputPath to pass all the result to next lambda.
1
      "InputPath": "$",

use this solution, the state input will be pass through the lambda one by one.
If you want to get a part of result to next state lambda, you can also use the Parameters or InputPath to select the neccessary input.

all statemachine code Link to heading

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
  "StartAt": "dispatcher",
  "States": {
    "dispatcher": {
      "Type": "Task",
      "Resource": "arn:aws:lambda:ap-northeast-1:[myAccountId]:function:dispatcher",
      "ResultPath": "$.dispatcher_result",
      "Next": "check-dispatcher_result"
    },
    "check-dispatcher_result": {
      "Type": "Choice",
      "Choices": [
        {
          "Or": [
            {
              "Variable": "$.dispatcher_result.dispatcher_code",
              "StringEquals": "1"
            },
            {
              "Variable": "$.dispatcher_result.dispatcher_code",
              "StringEquals": "2"
            }
          ],
          "Next": "business-logic-lambda1"
        },
        {
          "Or": [
            {
              "Variable": "$.dispatcher_result.dispatcher_code",
              "StringEquals": "3"
            },
            {
              "Variable": "$.dispatcher_result.dispatcher_code",
              "StringEquals": "4"
            }
          ],
          "Next": "business-logic-lambda2"
        }
      ],
      "Default": "business-logic-lambda2"
    },
    "business-logic-lambda1": {
      "Type": "Task",
      "InputPath": "$",
      "Resource": "arn:aws:lambda:ap-northeast-1:[myAccountId]:function:business-logic-lambda1",
      "End": true
    },
    "business-logic-lambda2": {
      "Type": "Task",
      "InputPath": "$",
      "Resource": "arn:aws:lambda:ap-northeast-1:[myAccountId]:function:business-logic-lambda2",
      "End": true
    }
  }
}

Reference Link to heading

You can find more information on Input and Output Processing in Step Functions.