amazon-web-servicesaws-lambdaaws-step-functions

Global variable alternative in a AWS Step Function execution


Im running a workflow using a step function (with SAM), when I needed to send information between lambdas I've used events and everything was perfect! But now, I need that almost every lambda in my workflow have access to a constant received in the invocation input of the step function (it changes on every execution) like a global variable.

I know that I can solve it by returning it in every lambda output but I think that it is a very ugly solution :(

Is there any way to access the context of the execution and add data to it from a lambda in the step function ? Any other solution would be cool too.


Solution

  • Yes, see https://docs.aws.amazon.com/step-functions/latest/dg/input-output-resultpath.html#input-output-resultpath-append

    You can keep the input of the state machine execution and combine it with the result of the state.