Search code examples
pythonamazon-web-servicesaws-cdkaws-step-functions

How to combine context object with task input in step function Lambda invoke?


aws_stepfunctions_tasks.LambdaInvoke.__init__ takes an input_path argument, which defaults to $ - the entire task input. How can I combine that with the context object ($$), since my Lambda needs information from both? Or do I need to use something else, like the payload argument, to specify more than one input?


Solution

  • To pass both, the payload and context to lambda function, you will need to wrap the original input inside the another attribute for instance Payload

    {
    ....
    "ACCESS": {
          "Type": "Task",
          "Parameters": {
            "Payload.$": "$",
            "Context.$": "$$"
          },
          "Resource": "my_lambda_arn",
          "Next": "SLACK_MESSAGE"
        }
    ...
    }