AWS CloudWatch Events

Issues with cron settings:

Today I learned the hard way, and much later than the ideal case, that the AWS CloudWatch event cron settings does not support advanced cron configurations!

I created an AWS Lambda with EFS and wanted to schedule it to run every other Monday. After trying different solutions in the cron settings, the only config I could make work was one to run the lambda every Monday:

0 14 ? * 2 *
AWS cron settings for every Monday execution

If AWS supported more advanced syntax, then we I could have had two different jobs running the lambda, one on the first Monday and the second on the third Monday:

0 14 * * 2#1 * - to run lambda on the first Monday of the month.
0 14 * * 2#3 * - to run lambda on the third Monday of the month.
advanced cron syntax - schedule for 1st and 3rd Monday executions

We can't have nice things, so this cannot be scheduled. Instead, the best I can do is, every 1,15 days in the month, which don't necessarily land on Mondays:

0 14 1,15 * *
AWS cron job for every 1st and 15th day of the month execution

The next best thing will be to execute the lambda every Monday and in my lambda code, check if the Monday is the 1st or 3rd Monday of the month and then execute the lambda code only in these cases.

🤷‍♀️

Will need to look into modifying my code, but it would be much easier if it could be done from the cron settings.

Show Comments