gk-iwise
gk-iwise

Reputation: 31

AWS Step function Invoking lambda in a loop

I have lambda which returns bunch of records from a database. I iterate through each of the record and invoke another lambda. After all the rows are complete, I would like to call another lambda which does some validation and sends out an email.

I am able to achieve this flow using Iterate pattern (https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-create-iterate-pattern-section.html)

The issue is the call to lambda for each of the row is synchronous i.e the loop wait for the lambda to complete before invoking for the next row. This is not acceptable for our requirement as we want the step function to complete in few seconds.

I would like to know if there is way to make the call to lambda in loop asynchronous and that the final step can wait for all lambda instance to complete and continue with further processing.

Upvotes: 2

Views: 2899

Answers (1)

thomasmichaelwallace
thomasmichaelwallace

Reputation: 8464

It sounds to me like you're looking for the parallel state: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-parallel-state.html

This would allow you to pass in an array of rows and have the lambdas all be invoked in parallel. The responses would then be recombined, very much like promise.all() in node.

Upvotes: 1

Related Questions