AWS Lambda schedule a delayed execution to run once

一曲冷凌霜 提交于 2019-12-24 07:56:53

问题


I have an API Gateway with Lambdas behind, for some of the endpoints I want to schedule an execution in the future, to run once, for example the REST call was made at T time, I want that lambda to schedule an execution ONCE at T+20min.

The only solution I found to achieve this is to use boto3 and Cloudwatch to setup a cron at the moment the REST call was made, send an event with the payload, then when the delayed lambda runs, it removes the rule.

I found this very heavy, is there any other way to achieve such pattern ?

Edit: It is NOT A RECURRING Lambda, just to run ONCE.


回答1:


One option is to use AWS Step Functions to trigger the AWS Lambda function after a given delay.

Step Functions has a Wait state that can schedule or delay execution, so you can can implement a fairly simple Step Functions state machine that puts a delay in front of calling a Lambda function. No database required!

For an example of the concept (slightly different, but close enough), see:

  • Using AWS Step Functions To Schedule Or Delay SNS Message Publication - Alestic.com
  • Task Timer - AWS Step Functions


来源:https://stackoverflow.com/questions/56937218/aws-lambda-schedule-a-delayed-execution-to-run-once

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