how to trigger 2 target lambda's based on source lambda successful execution

0

Hello, how to trigger 2 target lambda's based on source lambda successful execution?

Source lambda is sending SQS message after successful execution.I need to run 2 lambda's based on source lambda success.Can you please suggest the option to run Target1 and Target2 lambda's.

  1. Can we connect 2 lambda's to one SQS?
  2. Sometimes SQS message is hitting twice and lambda also running twice.
2 Answers
0

Consider using AWS Step Functions to coordinate the components of distributed application. Here is a quick comparison between Step Functions and SQS. Their use cases are not mutually exclusive; you can leverage both for complex application. Here is a short tutorial on building a serverless workflow application using both services.

You could alternatively use Lambda Destinations and Event Bridge and/or SNS to build the orchestration, but if you expect the complexity of you application to grow I would recommend using AWS Step Functions

I hope this is helpful. Please let me know if you have any other questions.

AWS
answered 6 months ago
0

You have several options:

  1. Instead of sending a message to SQS, send a message to an EventBridge bus and add a rule with two targets, for the different functions. BTW, if your function is invoked asynchronously, you don't need to send the message from within the function itself, rather you can use Lambda Destinations.
  2. If you must send the message to SQS, you can use EvebtBridge Pipes to consume the queue and either, send the message to an EventBridge bus, or invoke a StepFunctions workflow, which will run the two functions, probably in a Parallel state.

You should never use two different consumers on a single queue, as some of the messages will go to the first consumer and some will go to the second, without any control on your side.

profile pictureAWS
EXPERT
Uri
answered 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions