在指定的未来时间仅调用一次 AWS Lambda 函数

问题描述:

我希望能够设置调用 AWS Lambda 函数的时间,然后仅在那时调用该函数.例如,我希望我的 Lambda 函数在 2017 年 12 月 19 日晚上 9:00 运行.我不希望它重复,我不希望它现在调用,就在 19 日晚上 9:00.

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:00pm on December 19th, 2017. I don't want it to repeat, I don't want it to invoke now, just at 9:00pm on the 19th.

我知道 CloudWatch 提供了预定事件,并且我在想,当输入安排此提醒的时间时,会创建一个 CloudWatch 预定事件以从现在起在该时间段内触发(例如,如果您在8:22 到晚上 9 点运行,它将是 38 分钟),然后它在晚上 9 点调用 Lambda 函数,然后删除 CloudWatch 计划事件.我的问题是,当创建 CloudWatch 计划事件时,它会立即执行,然后按指定的时间间隔执行.

I understand that CloudWatch provides Scheduled Events, and I was thinking that when a time to schedule this reminder for is inputted, a CloudWatch Scheduled Events is created to fire in that amount of time from now (so like if you schedule it at 8:22pm to run at 9pm, it’ll be 38 mins), then it invokes the Lambda function at 9pm which then deletes the CloudWatch Scheduled Event. My issue with this is that when a CloudWatch Scheduled Event is created, it executes right then, then at the specified interval.

任何其他想法将不胜感激,因为我想不出其他解决方案.提前致谢!

Any other ideas would be appreciated, as I can't think of another solution. Thanks in advance!

您可以使用以下语法安排 lambda 事件:

You can schedule lambda event using following syntax:

cron(Minutes 小时 Day-of-month Month Day-of-week Year)

注意:所有字段都是必填字段,时区仅为 UTC

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

请参阅此 AWS 文档 了解详情.

Please refer this AWS Documentation for Details.

谢谢