I have a number of users who can create multiple triggers to call the function at specific time i.e. a user can set 5 different triggers to execute a function at different times. So, I want to create a function which runs on the schedule event set by user i.e. dynamically. Then at the scheduled time function will execute and send the mail or sms. Can somebody help me in deciding what is the best way to accomplish this, should i set a cron which executes every minute and check for any created trigger for evey user ?
- Store the trigger records in DynamoDB - multiple triggers means multiple records, each with a different execution time.
- Enable Time To Live in DynamoDB and configure that table such that when the execution time is reached, the record will be deleted.
- Create a lambda that listens to DynamoDB deletion events. When it detects that an event should be triggered, it does so, using the data sent from dynamo.
One-time Scheduled Events
Thanks for replying @TrentBartlem but my triggers are reoccurring, like it will run every day of month or week. The solution you give is for one time trigger only.
So, have 2 lambdas listen to expired events.
- Lambda #1 determines whether a copy of the trigger needs to be created for a later execution time.
- Lambda #2 executes the triggered event.
Create Cloud Watch Events via the API and trigger your Lambda?