Remotec
Remotec

Reputation: 10758

Is there a way to disable certain parallel processes inside a step function?

My scenario is as follows:

When an event occurs, several processes need to be executed in parallel.

A step function seems ideal for this:

e.g.

Event received:
- Parallel 1 - Send an SMS message
- Parallel 2 - Send an email
- Parallel 3 - Write data to a database
Gather all completed results to determine success / failure.

However, dependant on the type of event I may want to only execute a few of the processes.

An example would be: the incoming customer data does not contain an email address so we want to skip the email process.

Is there a way for the step function to enable, disable certain parallel processes dependant on the type of initial event?

Upvotes: 0

Views: 1129

Answers (1)

fedonev
fedonev

Reputation: 25669

Here are two ways to apply yes-no decision logic to each parallel branch:

  1. Add a two-branch Choice State at the start of each parallel branch. For instance, payloads matching {"Variable": "$.email", "IsPresent": true} continue to the Parallel 2 branch, but otherwise bypass it.
  2. Perform the parallel tasks in Lambdas using the SDKs. Use branching logic at the start of each Lambda to decide whether to process the payload.

Upvotes: 1

Related Questions