[英]AWS Cron schedule expression
I want to deploy function to AWS Lambda with using serverless framework in NodeJS/Typescript.我想在 NodeJS/Typescript 中使用无服务器框架将 function 部署到 AWS Lambda。 Here is my serverless.yml:
这是我的 serverless.yml:
service: backend
plugins:
- serverless-webpack
provider:
name: aws
region: eu-central-1
runtime: nodejs14.x
stage: dev
functions:
createDailyStatistics:
handler: dist/services/schedules.scheduleDailyStatistics
events:
- schedule:
rate: cron(0 0 * * *)
enabled: true
can someone tell me, why after launch serverless deploy
i got an error like this:有人可以告诉我,为什么在启动
serverless deploy
后我收到这样的错误:
CREATE_FAILED: CreateDailyStatisticsEventsRuleSchedule1 (AWS::Events::Rule)
Parameter ScheduleExpression is not valid. (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException; Request ID: xxx; Proxy: null)
My expression - 0 0 * * *
is a standard cron expression but AWS not handle this?我的表达式 -
0 0 * * *
是标准的 cron 表达式,但 AWS 不处理这个? I want to launch this functino on every day at midnight.我想在每天午夜启动这个功能。
Thanks for any help!谢谢你的帮助!
AWS uses the extended CRON expression format: AWS 使用扩展的 CRON 表达式格式:
Please notice, there are 6 fields in the expression: Minutes
, Hours
, Day of month
, Month
, Day of week
and Year
.请注意,表达式中有 6 个字段:
Minutes
、 Hours
、 Day of month
、 Month
、 Day of week
和Year
。
In your case, you provide only 5 values.在您的情况下,您只提供 5 个值。 I'm guessing you were most likely using crontab.guru to create your cron expression, meaning that you want an event to fire
At 00:00
.我猜你最有可能使用crontab.guru来创建你的 cron 表达式,这意味着你希望事件
At 00:00
触发。 In that case, for AWS you would want to have something like this: 0 0 * *? *
在这种情况下,对于 AWS,您会希望有这样的内容:
0 0 * *? *
0 0 * *? *
. 0 0 * *? *
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.