Vikas
Vikas

Reputation: 876

AWS EventBridge - Use output of first target as input to the next

A rule in AWS EventBridge allows us to provide upto 5 targets. For each of these targets, we have some options to choose the input - based on the event that matched the rule. Is there a way to pass the output of the first target (lambda function) as the input to the next (another lambda function).

I know we can do this by triggering an SNS at the end of the first lambda function. But, I am looking for a way to do this within the EventBridge.

Thanks for your help

Upvotes: 0

Views: 1263

Answers (2)

blr
blr

Reputation: 968

I'd agree with @paritosh answer that Step-functions makes more sense for a workflow but if you need something more light-weight (and don't want to learn one more thing); you can use set Eventbridge as the lambda destination. Lambda should then send the event back to Eventbridge via a PutEvents api call https://aws.amazon.com/blogs/compute/introducing-aws-lambda-destinations/

If you want to change the input before triggering the lambda, you can use InputTransformer https://docs.aws.amazon.com/eventbridge/latest/userguide/transform-input.html

Upvotes: 0

Paritosh
Paritosh

Reputation: 1129

A cleaner way to do this would be to have Eventbridge hand over the event to a Step Functions state machine and have 5 steps in that state machine.

Step functions allow you to consume output from first step in the second step and so on.

More on Step Functions here.

More on Lambda with Step Functions here.

Upvotes: 1

Related Questions