Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Express Step Function execution within Express Step Function

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.

like image 985
RVid Avatar asked Oct 20 '25 13:10

RVid


2 Answers

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"
}
like image 193
adamwong Avatar answered Oct 23 '25 08:10

adamwong


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.

like image 30
Jason Wadsworth Avatar answered Oct 23 '25 09:10

Jason Wadsworth