An external process calculates a timestamp related to an ID, for example:
id | timestamp |
---|---|
1 | 1695221055 |
2 | 1695221079 |
I have a Lambda function that I want to trigger when that timestamp is reached, and I need to have the ID of the fulfilled timestamp. In other words, when the time in UTC reaches that timestamp, I want the Lambda function to be triggered having that ID of the timestamp that made it trigger. Please note that this record can be updated due to my external process, and the timestamp may be set to a further date.
The architecture I considered was using a TTL (Time to Live) feature in DynamoDB with that timestamp column set as TTL, and DynamoDB Streams listening to it, so when deleted, trigger my lambda. However, DynamoDB can take up to 48 hours to delete the record, which would result in the deletion event arriving much more later than I require, due to I need almost real time.
Is there a way to achieve this? It doesn’t have to be in DynamoDB; another type of architecture may work for me.
2
Answers
For this you can use EventBridge Scheduler. So when you create the item, capture that creation in DynamoDB Streams, have a Lambda function that creates an EventBridge Scheduler that invokes a Lambda function at the time you specify and with the data you require.
EventBridge scheduler has a granularity of 1 min, instead of days compared to TTL.
You can invoking functions by Function URLs.
timestamp
should be passed as a parameter to lambda when you call the URL.This way, you can obtain an accurate ID.Lambda requires time for initialization, and the startup time and program execution time may differ. Using parameter passing is a good choice.Of course, you can use any other method that supports parameter passing, such as mq, sqs, aws cli, aws gateway, etc.You can also use lambda to call lambda.
Reference: https://docs.aws.amazon.com/lambda/latest/dg/lambda-invocation.html