Selecting in States.StringToJson function

Viewed 27

It there is a way to process the result of States.StringToJson intesic function directly ? 

Currently in a step function, I try to handle the error from another synchronous step function call :

 "OtherStepFunction": {
        "Type": "Task",
        "Resource": "arn:aws:states:::states:startExecution.sync:2",
        "Parameters": {
          "StateMachineArn": "otherstepFunctionCall",
          "Input.$": "$"
        },
        "End": true,
        "Catch": [
          {
            "ErrorEquals": [
              "States.ALL"
            ],
            "Comment": "OtherStepFunctionFailed",
            "Next": "StatusStepFunctionFailed",
            "ResultPath": "$.error"
          }
        ]
      },

All errors goes in a pass flow named StatusStepFunctionFailed, with the errors output in $.error path.

The $.error is composed of the error type and the cause as an escapedJson string.

"error": {
   "Error": "States.TaskFailed",
   "Cause": "{\"ExecutionArn\":\"otherfunctionarm:executionid\",\"Input\":\"foooooo\"}"
 }

Is there any way to extract only the ExecutionARN from this input ? In my pass step, I convert the Cause path as a json, but i didn't find a way to select directly the ExectionARN part. The following :

"reason.$": "States.JsonMerge($.error.Cause).ExecutionArn"

return The value for the field 'reason.$' must be a valid JSONPath or a valid intrinsic function call (at /States/HandleResource/Iterator/States/StatusStepFunctionFailedHandleJSON/Parameters)

My current workaround is to use 2 pass flow, first convert the output and then formating.

0 Answers
Related