What should I be using instead of event bus to trigger a series of lambda function every 5 minutes?

I have two lambda functions.

Function A I am calling 5 times with different params via event bridge. I now need to increase that to 6 times with different params.

In addition I now have a new lambda function B I want to run before these 6 calls.

The rule I was use for running the original 5 targets every 5 minutes has a limit of 5 targets and I realise now they run asynchronously where ideally I want them to run sequentially to reduce server load.

Given that the eventbridge rule is limited to 5 targets I think it clearly wants me to use a different approach/service, but I am not sure how/what.

Any advice to the approach would be appreciated.

You could use Step Functions. You can configure each step of the state machine with the Lambda function you want to call and the parameters you want to pass. The steps will be executed sequentially. If you need it to run every 5 minutes, create an Event Bridge rule that triggers the state machine at that interval.

Have a look at Step Functions.

Have you already considered using a step function with a loop, and inside the loop you have the lambda triggering (maybe mediated by sqs or sns) then a wait stage of 300 secs?

This is exactly why Step Functions exists

i’d use dynamodb and ttl. each row is one of these “params” and set its ttl to five minutes.

wire a lambda to the dynamo tables stream events and handle the deleted events by publishing to a topic or queue to kick off the job and either have the job create a new record in your orchestration table or have the stream listener do it after it publishes

DynamoDB TTL is not guaranteed to delete an item at the time specified by the TTL making this a non-tenable solution.

From the docs:

Items with valid, expired TTL attributes may be deleted by the system at any time, typically within a few days of their expiration.

this hasn’t been my experience and don’t act like this is a deal breaker. you can also easily work around this by doing a scan on the whole of five items.

Agree with others that Step Functions is probably what you’re looking for.

Also, thank you for picking up the hint that this particular service limit is trying to give you. It isn’t universally true, but running up against limits like this one is often a signal that there is an anti-pattern at play.

This seems like a really complex way to solve for OPs situation. What are the advantages of this approach?

orchestrating workflows in dynamodb is very common

how to control or set the inverval using eb rules? or are you talking about event bridge scheduler?

depends on the business’ tolerance tbf, it’s still an option

It would probably work, but you can’t rely on the exact expiration time of the TTL. This makes it a sub optimal pattern. Others services, such as EventBridge scheduler are therefore more suitable.

sure, but it works just fine for a few jobs.

Why the down vote? It might be ‘fine’ but most of the engineers out here aim for the best solution within constraints of budget and time. Your solution relies on the TTL of items in dynamodb. The docs tell us, as someone already mentioned to you, that the TTL should not be relied on. It can take up to two days after expiration to actually trigger a delete.

Step Functions with express workloads sounds like what you need. Let eventbridge invoke your state machine.

downvote because the ask isn’t what’s the most elegant solution. the question was how to orchestrate two lambdas. plenty of people suggested step function. that’s a little much for something that can be accomplished with dynamodb streams.

additionally, your solution only boy provides a service suggestion and ignores the comment about needing two lambs to run synchronously.

your solution didn’t actually address the issue. it was proposed to so that you could put me down.

problem is i actually use these tools every day so i know how the should behave on a table with six rows in it.

If the lambdas have to run synchronously, I would advocate for parallel execution in a step function.

We are all to learn here. Not to compete or “put you down”. Let’s help each other out with combining knowledge and insights.

jupiter not reading ops question. the need to be run after the other. your gonna fail the tests if you don’t fully read the questions