Cherry
Cherry

Reputation: 33618

How to prevent concurent runs of a state machine in AWS Step Functions?

Is there a way to prevent concurrent execution of AWS Step Functions state machines? For example I run state machine and if this execution is not finished and I run this machine again I get an exception.

Upvotes: 4

Views: 3334

Answers (2)

lexicore
lexicore

Reputation: 43709

You can add a step (say, with a Lambda function) which would check if the same state machine is already being executed (and in which state). If this is the case, the lambda and the step would fail.

Depending on what you want to achieve, you can additionally configure a Retry so that the execution will continue once the old state machine has finished.

Upvotes: 2

A.Khan
A.Khan

Reputation: 4002

I don't think it is possible according to StartExecution API documentation:

StartExecution is idempotent. If StartExecution is called with the same name and input as a running execution, the call will succeed and return the same response as the original request. If the execution is closed or if the input is different, it will return a 400 ExecutionAlreadyExists error. Names can be reused after 90 days.

Upvotes: 0

Related Questions