But i want to trigger the third lambda function when another two lambda executed successfully.

1 year ago 31 Replies
VB
Venkatesh Balasubramanian
4 years ago

Hi,

I have two lambda function which update the db using flat files trigger from S3. I have third lambda function which insert the data based on previous lambda function but doesn't have any trigger. But i want to trigger the third lambda function when another two lambda executed successfully. Can anyone suggest me the solution using SNS or SQS or SES ??

4 Likes

Replies

Ganesh Bhosale 4 years ago

Use Step function. It is lambda orchestration service.

5 Likes
Sheng-Yu Tsai 4 years ago

Are the two lambda functions that update the db triggered at the same time? or in a sequence?

1 Like
Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai sequence

Sheng-Yu Tsai (4 years ago)

If you don't mind, call another Lambda asynchronously in the end of the code of the previous lambda will fulfill your requirement.

S3 -> Lambda1 -> Lambda2 -> Lambda3

Sheng-Yu Tsai (4 years ago)

or more complexly,

S3 -> Lambda1 -> SQS -> Lambda2 -> SQS -> Lambda3

Bharani Siva (4 years ago)

Sheng-Yu Tsai We can go with SQS fifo queue right ?

Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai user will place the file into S3 so it will trigger two lambda function. If two are executed fine then i need to trigger third lambda or anyone is failed i need not trigger third lambda

Sheng-Yu Tsai (4 years ago)

Bharani Siva yes, FIFO queue is a great option

Bharani Siva (4 years ago)

Cool Venkatesh Balasubramanian Why do we try that ?

Venkatesh Balasubramanian (4 years ago)

Bharani Siva actually two lambda update two different table so once it is executed based on the data in the table i need to execute some store procedure in the third lambda function

Jamie Skelton (4 years ago)

Can anyone recommend a lab to test this?

Bharani Siva (4 years ago)

Venkatesh Balasubramanian So you want first two lambda function to execute concurrently and want 3rd lambda function to be executed ?

Venkatesh Balasubramanian (4 years ago)

Bharani Siva crct

Venkatesh Balasubramanian (4 years ago)

First two will be trigger by S3 and third one i don't have any idea

Sheng-Yu Tsai (4 years ago)

Are the two lambda functions triggered by the same S3 bucket?

Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai no different S3 bucket

Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai can you share any reference link ?? Thanks

Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai i mean for fifo SQS with lambda

Sheng-Yu Tsai (4 years ago)

If you have to wait for two concurrent lambdas to finish, I think Lambda + FIFO SQS cannot fulfill your need.

Sheng-Yu Tsai (4 years ago)

check this one. see if this fits

Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai Thanks a lott. I will check that further more deep. Have a good day 😀

Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai this is not a parallel processing it is sequence processing

Sheng-Yu Tsai (4 years ago)

could you elaborate on which part does not work for your case?

Venkatesh Balasubramanian (4 years ago)

State Function is a one i need to manually execute it right, but actually it should be trigger by putting file into S3

Venkatesh Balasubramanian (4 years ago)

Sheng-Yu Tsai

Sheng-Yu Tsai (4 years ago)

I mean this is a concept. You have various ways to achieve this idea. Probably you can think about that first by yourself.

Anyway, I'll provide one solution. S3 Bucket1 -> SNS

use the SNS topic to trigger two Lambdas

  1. new Lambda -> Step Funtion
  2. Lambda1 -> db table1

Ganesh Bhosale (4 years ago)

Venkatesh Balasubramanian Relevant this use case, Step function supports integration with CloudWatch events. You don’t need to execute manually. You can subscribe to S3 CloudWatch event.

Fred Damstra 4 years ago

I’d have each of the first two write a completion record to either a database or S3. The third function would trigger off either of the first two, and begin by checking for two completion records. If only one is found, it would abort.

0 Likes
Kalyan Tilak 4 years ago

Go for Step function

0 Likes
Sanjay Singh 4 years ago

Go for step function

0 Likes
Venkatesh Balasubramanian 4 years ago

Can we trigger step function without manually ??

0 Likes