I know about the provisioned instance configuration for lambda functions. Is it possible to run multiple instances of a lambda function on a timer basis? I know generally we use CloudWatch Events for this, just not how to specify multiple instances. To be clear, I want something like: I want 10 instances of my function to run at "2022-02-02 10:10:10".
4
-
1Sounds like an XY problem - why would you want 10 separate instances?Ermiya Eskandary– Ermiya Eskandary2022-02-03 11:57:42 +00:00Commented Feb 3, 2022 at 11:57
-
Because I need to have multiple workersRicardo Peres– Ricardo Peres2022-02-03 11:58:19 +00:00Commented Feb 3, 2022 at 11:58
-
If this is a continuation of some of your previous questions like this one: stackoverflow.com/questions/70863723/… then I think you need to go back and reevaluate using SQS and setting up the SQS queue as an event source for Lambda. You wouldn't need to setup these CloudWatch schedules at all.Mark B– Mark B2022-02-03 14:25:12 +00:00Commented Feb 3, 2022 at 14:25
-
No, it's a different issue, but thanks for asking and for commenting on it!Ricardo Peres– Ricardo Peres2022-02-03 14:27:04 +00:00Commented Feb 3, 2022 at 14:27
Add a comment
|
1 Answer
Some options:
- Create 10 identical CloudWatch events
- Create a new Lambda that is triggered by your single CloudWatch event. The new Lambda would invokes your worker Lambda function 10 times asynchronously
- Create a Step Functions state machine that triggers 10 Lambda invocations, and trigger the step function on a schedule
3 Comments
Ricardo Peres
Thanks, but although these are hypothetical options, I don't think some of them are practical. I am interested, though, in step functions, it might be an option, yes, I'll have to dig into that.
Mark B
I'm not sure why any of them are necessarily impractical. If you were using something like Terraform then the first option would be a matter of adding a single line of code to your Infrastructure as Code. The 2nd option is something I see people doing fairly regularly.
Ricardo Peres
Yes, maybe I'm wrong, maybe they are all viable options.