How to implement manual approval in AWS Step Functions? What's the recommended workflow engine between SWF and Step Functions?
Asked Answered
O

1

5

Step Functions now support callback features to support manual approval. I wanted to know how the task token is generated and if we can pass our own task token string so that we do not require to store it for marking task passed/failed.

Also, for a workflow that requires multiple client interactions for proceeding to the next state, is it recommended to use Step Functions or SWF (and its signals).

USECASE: I have multiple steps in workflow where we need to execute fail scenario if the timer reaches 6 months or if in those 6 months, user actually approves, then the workflow needs to execute to passed scenario.

Oast answered 31/1, 2021 at 21:35 Comment(0)
S
8

AWS Step Functions generates the task token for you when you use any of the service integration patterns that support the .waitForTaskToken integration. You can't generate your own token and pass it in as part of the integration. See the Wait for a Callback with Task token documentation for more information and examples.

For a workflow that requires multiple client interactions before proceeding to the next state, I'd personally use a Step Functions workflow. If the client interactions happen in a defined order, then I'd simply write a series of .waitForTaskToken style service integrations that happen in serial, where each integration would then allow the next client interaction to happen (in whatever way is appropriate for what you're building, e.g. executing Lambdas, putting items in an SQS Queue, etc). However, if the client interactions can happen in any order and you want to basically pause the state machine until they're all done, I would consider delegating all of the monitoring of for the related client interactions into an Activity and just transition to that Activity's task to wait for the Activity to report back with a sendTaskSuccess call or a timeout if they didn't all finish in the time you'd want them to.

Suzetta answered 3/2, 2021 at 9:30 Comment(2)
read through the activity route. But this seems like a workaround for a basic workflow functionality. does Step function have support for manual signals (like SWF) ?Oast
Every Step Functions state machine can only be in a single given state at any given time. Some of these states are Task states, where work happens. That work happens by invoking another AWS service via a supported API integration, or by computation that can happen anywhere (via a polling worker process that discovers work to be done and reports back to Step Functions when that work is complete) with the concept of an Activity. Hopefully this helps inform why I structured my answer the way I did.Suzetta

© 2022 - 2024 — McMap. All rights reserved.