Home > Back-end >  How to access input of state machine in any node at AWS Step Functions
How to access input of state machine in any node at AWS Step Functions

Time:02-24

Let's say I have this state machine in AWS Step Function:

step function example

And I had started it with this input:

{
  "item1": 1,
  "item2": 2,
  "item3": 3
}

It's clear for me that Action A is receiving the input payload. But, how can Action C access the state machine input to get the value of item3? Is it possible?

Thanks!!

CodePudding user response:

Typically, the data available in Action C will be dependent on what the result/output of Action B is.

However, if you just care about the original input to the state machine execution, you can set the payload of Action C using the Context Object.

// roughly 
 "Action C": {
   "Type": "Task",
   "Resource": "arn:aws:states:::lambda:invoke",
   "Parameters": {
     "Payload.$": "$$.Execution.Input",
     "FunctionName": "<action c lambda>"
 },

Check out the AWS documentation for Context Object

  • Related