4
votes

We're trying to have a lambda on AWS, that is scheduled to run every Monday at 9:45am.

Our cron expression is in the form of:

cron(45 9 ? * MON *)

AWS docs explicitly state, that you there are six required fields for the crons (you can ignore seconds) - see documentation here: https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html

However, deploying the lambda results in an error:

An error occurred: ConsumerEventsRuleSchedule13 - Parameter ScheduleExpression is not valid. 
(Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException)

I've managed to fix it, by adding seconds to the expression:

cron(0 45 9 ? * MON *)

However, I'm still confused why the original expression was invalid? AWS documentation (linked above) even provides a working expression for a task running every work day (Monday - Friday): cron(0 18 ? * MON-FRI *) which looks just like what we tried to use originally, minus the weekday range (since we want one specific weekday).

Any clues?

1
That's weird. You cron looks good. I even tested the original one by creating a CloudWatch Rule and it worked just fine. Maybe it's a bug. I'd get in touch with AWS to see if they know anything about it.Thales Minussi
How were you creating this? Using aws-cli?Michael - sqlbot

1 Answers

0
votes

Have you tried sam package before deploy? you might using old code which cron is wrong... try sam package --s3-bucket your-bucket-name --output-template-file packaged.yaml