4

In the Standard Workflow we can happily invoke another Standard workflow using

{
  "Type": "Task",
  "Resource": "arn:aws:states:::states:startExecution.sync:2",
  "Parameters": {
    "StateMachineArn": "${NestedStateMachineArn}",
    ...
  }
  ...

When we try to do the same with Express workflow we of course get the Express state machine does not support '.sync' service integration. That is stated by aws so expected behaviour.

Is there another way to execute Express workflow from another Express workflow and somehow get the execution result/output? I can think of a last resort - use Lambda function to execute the nested workflow sync and wait for a response, that said, it will increase the cost having a function waiting for StateMachine needlessly.

I tried to look around but couldn't find this documented anywhere.

RVid
  • 1,207
  • 1
  • 14
  • 31
  • 1
    Please change your selected answer from the one saying this is not possible to the one that explains how this is possible. – falsePockets Mar 28 '22 at 21:47

2 Answers2

4

You can execute Express executions synchronously using the StartSyncExecution API, which is now supported as an AWS SDK integration in Step Functions using "Resource": "arn:aws:states:::aws-sdk:sfn:startSyncExecution".

"NestedExpressWorkflow": {
  "Type": "Task",
  "Resource": "arn:aws:states:::aws-sdk:sfn:startSyncExecution",
  "Parameters": {
    "StateMachineArn": <your_express_state_machine>,
    "Input.$": "$"
  },
  "Next": "NextState"
}
adamwong
  • 1,035
  • 6
  • 11
3

You can execute another workflow, you just can't wait for the results. I believe you just need to remove .sync from the resource. If you are needing to wait for the results of the second function you won't be able to do that within an express workflow.

From Service Integrations with AWS Step Functions

Standard Workflows and Express Workflows support the same set of service integrations but do not support the same integration patterns. Express Workflows do not support Run a Job (.sync) or Wait for Callback (.waitForTaskToken). For more information, see Standard vs. Express Workflows.

Jason Wadsworth
  • 8,059
  • 19
  • 32
  • I should have clarified in my question, I am looking to get output from the nested Step Function. I have edited and added that in. – RVid Mar 19 '21 at 19:35
  • 1
    Unfortunately there isn't a way to do that, outside of what you described. I was trying to think of another way, but I don't think so. The API Gateway integration with step functions has the same limitation for express workflows, so while you can make a call to an API Gateway as a request/response from the first step function, the second would only be able to run an express workflow without getting the results. If the second step function could be a standard workflow then you'd have some options. – Jason Wadsworth Mar 19 '21 at 19:53