3
votes

What is the best way to invoke aws lambda function when multiple lambda functions have successfully finished?

So for example, LambdaA should run when LambdaB1, LambdaB2, ... LambdaBn have successfully returned success. Also, the last LambdaB function is not guaranteed to finish last...

1
You should look at AWS Step Functions, You can assign logic to take output from one lambda to start another with the output. You can assign waits as well as if statements based on the Lambda outputs. - Mark Hayward

1 Answers

3
votes

To answer your specific question, you need to use JavaScript Promises (I'm assuming you are using NodeJS) in your Lambda function. When all of the promises are fulfilled, you can proceed.

However, I do not recommend doing it that way, as your initial Lambda function is sitting idle, and being billed, waiting for the responses from the other functions.

IMO, the best way of achieving this parallel execution is using AWS Step Functions. Here you map out the order of events, and you will want to use Parallel States to make sure all tasks are complete before proceeding.