Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Step Function: state A pass lambda output to state B

My AWS lambda function check-version-lambda returns {"latest": "yes"} or {"latest": "no"}.

I have the AWS step function below, to pass above result to next state.

The next state process_version is a choice state, how do I retrieve the input inside Choices? What to fill in for <???>?

  {
      "StartAt": "check_version",
      "States": {
        "check_version": {
          "Type": "Task",
          "Resource": "arn:aws:lambda:us-east-1:000:function:check-version-lambda",
          "OutputPath": "$.latest",
          "Next": "process_version"
        },
        "process_version": {
          "Type": "Choice",
          "Choices": [
            {
              "Variable": "<???>",
              "StringEquals": "yes",
              "Next": "next_state"
            },
            {
              "Variable": "<???>",
              "StringEquals": "no",
              "Next": "next_state"
            }
          ],
          "Default": "next_state"
        }
      }
    }
like image 777
user1187968 Avatar asked Mar 09 '26 17:03

user1187968


1 Answers

In your "check_version" state, you can use

"ResultPath": "$.result",
"OutputPath": "$.result",

to explicitly configure the step function to put the result of the lambda (e.g. {"latest": "yes"}) into the result property of the input object. OutputPath tells the step function to only select that result as state output and hand it over to the next state.

In your "process_version" state, you should then be able to use:

"Variable": "$.result.latest",
"StringEquals": "yes",
"Next": ...

Source: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-example.html

like image 144
Simon Avatar answered Mar 13 '26 22:03

Simon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!