Set scheduled event dynamically

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 ?

  1. Store the trigger records in DynamoDB - multiple triggers means multiple records, each with a different execution time.
  2. Enable Time To Live in DynamoDB and configure that table such that when the execution time is reached, the record will be deleted.
  3. 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.

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?

http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchEvents.html#putRule-property