简体   繁体   中英

Send Input as Output on error for AWS Step Function

I'd like my state machine to continue execution even in the event of some state error early on. Most of my lambda functions output the same thing they take as input, so I'd like to be able to just pass on the input that the lambda that encountered the error as output to the next state. I tried

{
    "DeleteStuff": {
      "Type": "Task",
      "Resource": "MY_ARN",
      "Catch": [ {
        "ErrorEquals": ["States.ALL"],
        "ResultPath": "$InputPath",
        "Next": "FailedState"
      }],
      "Next": "checkStuff"
    }, ...

without any luck. Has anyone done this, or can anyone offer some assistance?

Thanks!

So the solution is the set ResultPath to null. Changing my state machine to

{
    "DeleteStuff": {
      "Type": "Task",
      "Resource": "MY_ARN",
      "Catch": [ {
        "ErrorEquals": ["States.ALL"],
        "ResultPath": null,
        "Next": "FailedState"
      }],
      "Next": "checkStuff"
    }, ...

gave me the desired behaviour.

if you just add a new path to the result path, it is added to the input:

{
    "ErrorEquals": ["States.ALL"],
    "ResultPath": "$.error",
    "Next": "Catch All Error Handler"
}

so if your input was:

{
    "data_a" : "aaa",
    "data_b" : "bbb"
}

output will be:

{
    "data_a" : "aaa",
    "data_b" : "bbb",
    "error" : "<error description>"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM