Siyavash
Siyavash

Reputation: 980

Fire aws lambda at a specific time

Let's say I have a booking system where I want to fire an aws lambda function to send an email or message to users, 10 minutes before their booking starts. I have looked online and found few solutions.

AWS Lambda + CloudWatch + DynamoDB:

Someone suggested adding the job to dynamodb and setting the TTL to when I want to notify the user and then connect cloudwatch to listen to remove triggers on the dynamodb. I did not like this method as it seems like a hacky way to do it.

ATrigger

This website provides a rest api which you can use to set up a scheduling job in the future. This is exactly what I need but the last update on their social media was in 2018. So probably not maintained.

Upvotes: 1

Views: 168

Answers (2)

s.hesse
s.hesse

Reputation: 2060

I believe using SNS is fine in your case. However, I want to show you an alternative. Depending on how you schedule your trigger, you could also start a Step Function execution which will trigger your Lambda function at a certain point. Step Function executions can run for up to a year and also trigger your Lambda function. An example I can imagine in your case: when someone books something in your system or schedules it using your API, you setup a Step Function execution which will trigger your Lambda function at point X (or "waits" until that point in time) before the booking time. I've answered a similar question here: https://stackoverflow.com/a/46935065/4831297 Maybe it's an alternative for you ;-)

Upvotes: 1

Marcin
Marcin

Reputation: 238747

Based on the comments, the accepted solution is to have a booking system to send an SNS message 10 minutes before the booking start. The SNS would then trigger lambda.

Upvotes: 1

Related Questions