4

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.

4 Answers 4

2

Going through the docs, I see that you can access the context object from each state in the state machine.

You can pass the information that you need to be global as the input to your state machine and then, access the state machine input from the context object.

You can refer the linked doc to see how to access the context object.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

You can access your step function invocation input from any state by accessing the context object in your state input parameters.

Select the AWS SDK integration type for your stage and forward the $$.Execution.Input context field to e.g. your lambda payload

pass state

enter image description here

enter image description here

The event for the lambda is

{
  "stepFunctionArguments":{
    "MyKey": "MyValue"
  },
  "payloadFromPreviousState": {
    "task1output": "foobar_result"
  }
}

Comments

0

An AWS contact at the company I work for says that AWS Step Functions will have global variables sometime this year. I'm not sure when, but it is in their road maps for this year

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.