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

*爱你&永不变心* 提交于 2019-12-03 05:49:01

You can schedule lambda event using following syntax:

cron(Minutes Hours Day-of-month Month Day-of-week Year)

Note: All fields are required and time zone is UTC only

Please refer this AWS Documentation for Details.

Thanks

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.

Invoking a lambda function via Events is asynchronous invocation option. By using CloudWatchEvent to trigger Lambda function we can use cron job but we are still facing issues as Lambda function triggered multiple times for the same cron schedule.PFB Link: https://cloudonaut.io/your-lambda-function-might-execute-twice-deal-with-it/

But this needs Dynamo DB to be implemented in your account and then make your Lambda function Idempotent.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!