Working in Node.js with AWS lambdas, I know:
- Lambda Context is passed to the handler as a second parameter
- Step Function Context can be obtained at various points in the data flow, the most useful being the Parameters step, where it can be added to the input of the lambda
- ResultSelector would work to add data (like Step Function Context) to the Result as well, except that transformation is ignored and not an allowed within a Catch statement.
- A Pass state can sit between states to also add data.
- That ResultPath can be used to append to the input the error within a Catch statement
My Desired Goal
Besides the error information, I want information from both the Lambda Context and the Step Function Context for the Lambda and Step State that is erroring (so specifically from the State
key, as the Execution
, StateMachine
, and Task
are all the same for any step) to be added to the final output result of a Catch to pass on to the Next step after.
The Challenge Faced in Achieving This Goal
However, it turns out that if Step Function Context is added using Parameters to the lambda input, that changed input it is still not accessible using ResultPath, as ResultPath only brings in the original input to the Step State, not the input as transformed by Parameters! You can test this with the data flow simulator (you need to be logged into an AWS account to utilize that). And of course a Pass state between the Catch and its Next call would no longer have access to the previous State Context that errored.
With my current codebase, I believe I have a workaround way of getting the Lambda Context fairly easily without a significant change as that is already being passed and used. However, accessing the Step Function Context through the lambda (via a Parameter passing to its input) would require hundreds of lines of code change in handlers and associated code to utilize it.
Ultimate Question
Is there some way I'm missing to directly add the Step Function Context from the State that is erroring to the Catch statement result, while also maintaining input and error info as is common in Catch statement use of ResultPath
?