Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws step function choice invalid path

Having a similar issue to this post: AWS Step Function returns condition path references error

However, I am still getting the same error.

Step code:

{
 "StartAt": "get_active_facebook_ad_accounts_lambda",
 "States": {
   "get_active_facebook_ad_accounts_lambda": {
     "Type": "Task",
     "Resource": "arn:aws:states:::lambda:invoke",
     "Parameters": {
       "FunctionName": "gods_country"
      },
     "OutputPath": "$.Payload",
     "Next": "ChoiceState"
},
   "ChoiceState": {
     "Type" : "Choice",
      "Choices": [
        {
          "Variable": "$.input",
          "NumericEquals": 1,
          "Next": "DefaultState"
        },
        {
          "Variable": "$.input",
          "NumericEquals": 0,
          "Next": "EndState"
        }
      ]
  },
   "DefaultState": {
      "Type": "Fail"
   },
   "EndState": {
     "Type": "Succeed"
   }
}
}

Execution plan errors: enter image description here

like image 402
dataviews Avatar asked Sep 14 '26 20:09

dataviews


1 Answers

It looks like your function is just returning a number. If this is the case you can likely do something like this:

{
 "StartAt": "get_active_facebook_ad_accounts_lambda",
 "States": {
   "get_active_facebook_ad_accounts_lambda": {
     "Type": "Task",
     "Resource": "arn:aws:states:::lambda:invoke",
     "Parameters": {
       "FunctionName": "gods_country"
      },
     "ResultPath": "$.activeAccounts",
     "Next": "ChoiceState"
},
   "ChoiceState": {
     "Type" : "Choice",
      "Choices": [
        {
          "Variable": "$.activeAccounts",
          "NumericEquals": 1,
          "Next": "DefaultState"
        },
        {
          "Variable": "$.activeAccounts",
          "NumericEquals": 0,
          "Next": "EndState"
        }
      ]
  },
   "DefaultState": {
      "Type": "Fail"
   },
   "EndState": {
     "Type": "Succeed"
   }
}
}

OutputPath is used to only pass a portion of the result on to the next step. So your previous state machine was looking for a property called Payload coming from the result of your lambda. I don't think this is the case - it looks like the result is just a number.

ResultPath specifies where the result of the step should be stored, and allows us to combine this result with any previous state. In this case in $.activeAccounts. You can then reference that property in subsequent steps.

For further information check out the AWS filtering documentation

like image 157
x112358 Avatar answered Sep 17 '26 14:09

x112358



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!