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.
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 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?
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
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.
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.
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.
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.