I am looking to schedule an AWS Lambda Function 24 hours after a specific event.
For example: if something is added to my database, 24 hours after that time, the AWS Lambda Function should run with specific parameters. This can be done with a function call to set the Lambda to run in 24 hours, or API call, (it does not have to be a webhook).
I have crawled the AWS documentation and cannot seem to find a solution.
I know it is possible to run the AWS Lambda Function on a cron schedule, but rather looking for something that can schedule it dynamically on a random basis.
Thanks so much!
You can Schedule Amazon CloudWatch Events, such that it can run an AWS Lambda function at a particular time. However, I'm not sure whether you would be able to pass specific parameters to it.
A better approach is probably to keep a list of events in a database (eg DynamoDB) and trigger a Lambda function every n minutes. The Lambda function could consult the DynamoDB table for the earlier event that needs to be run. If that earliest even is in the future, the function can simply exit. If the earliest event is due now (or in the past), it can call another Lambda function to do as you wish (with parameters pulled from the DynamoDB table).
So, you'd be using CloudWatch Events as the timer and the Lambda function as the logical "when to do what" controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With