'AWS StepFunction: end root Stepfunction execution from async execution

I'm trying to end an AWS stepfunction execution from a syncronous execution that it created.

I have a main stateMachine definition that starts a syncronous execution:

"Inventory process": {
  "Type": "Task",
  "Resource": "arn:aws:states:::states:startExecution.sync:2",
  "Parameters": {
    "StateMachineArn": "${StateMachineInventory}"
  },
  "Next": "Another activity"
}

And inside this syncronous stepfunction execution, I run an AWS Lambda that might raise a specific error:

"Lambda File Check": {
      "Type": "Task",
      "Resource": "${LambdaFileCheck}",
      "Catch": [
        {
          "ErrorEquals": [
            "NoInventoryPhaseRequired"
          ],
          "Next": "No Inventory Required"
        }
      ],
      "End": true
    }

Inside this No Inventory Required activity, I would like to end both the syncronous stepfunction execution AND my main stepfunction execution.

How would you do that using AWS Stepfunctions ?

Note: I know using several stepfunction definitions is a bit ankward, but in my context I need to to do it because the product is divised into several functional parts, that cannot live in the same definition.

Many thanks in advance :)



Solution 1:[1]

You can raise an exception from the lambda function and catch the error in the child/synchronous step function and set the next state as End.

As for the main step function, you will have to try experimenting on the same lines of raising an error can catching it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joshua Francis