Invoke AWS Lambda function only once, at a single specified future time

前端 未结 6 1504
无人共我
无人共我 2020-12-29 07:12

I want to be able to set a time to invoke an AWS Lambda function, then have that function be invoked then and only then. For example, I want my Lambda function to run at 9:0

6条回答
  •  天命终不由人
    2020-12-29 08:05

    You can use DynamoDB TTL feature to implement this easily, simply do the following:

    1- Put item with TTL, the exact time you want to execute or invoke a lambda function.

    2- Configure DynamoDB Streams to trigger a lambda function on item's remove event.

    Once the item/record is about to expire, your lambda will be invoked. you don't have to delete or cleanup anything as the item in dynamodb is already gone.

    NOTE: However the approach is easy to implement and scales very well, but there's one precaution to mention; using DynamoDB TTL as a scheduling mechanism cannot guarantee exact time precision as there might be a delay. The scheduled tasks are executed couple of minutes behind.

提交回复
热议问题