0
votes

Im looking for a serverless solution for an old system and its working like a charm, there is only one think I have no idea what is the best solution, here is the point

USER ---> API Gateway ---> Lambda ---> DynamoDB

User want to trigger a lambda in a specified time, example.

Im a user and I want to post a message in a dashboard (the function to do this is in a lambda) with some parameters saved in DynamoDB, and should be done tomorrow at 5.

User make a API request throw API Gateway, lambda is executed and put some info in DynamoDB, how can trigger another lambda with this info tomorrow ?

In the old system we have a cron with the time and when it should be triggered it just read the DB to get the parameters.

What can I use ? SQS ? CloudWatch Events ? with S3 ? DynamoDB stream ?

More info, could be like 10-20 executions per day.

2

2 Answers

0
votes

When the user invokes the lambda via the API Gateway and when you put the data in dynamo db you can at the same time have a message inserted in SQS with the exact time stamp when you want this user action to have a lambda invocation.

Now have a scheduled lambda that executes every minute or every 5 minutes or whatever suits you. The work of this lambda will be to poll all the messages of SQS and see if any schedule has reached for any of the message. If yes, invoke another lambda and pass this payload for invocation. If not then sleep till next polling time

0
votes

You could also do the same architecture in cloud. The on-prem cron can be replaced by a Cloudwatch cron schedule. So your second Lambda can be triggered based on the cron schedule and you scan your DB (dynamodb in this case) and do the processing.