Search code examples
amazon-web-servicescronamazon-cloudwatchaws-sam

AWS SAM Parameter ScheduleExpression is not valid when adding day of week


I am making a CloudWatch event and I need it to run every Friday at 11pm UTC. I attempted to turn this on by doing cron(0 23 * * FRI *) which according to all documentation I could find, is perfectly correct syntax. However it was failing every time I tried to deploy it.


Solution

  • I found the issue was that if you set a day of the week specifically, then you can not set the third parameter to * it needs to be set to ?. This makes logic sense because the third parameter is Day of Month and so you can't have it run every day of the month AND every Friday. Updating to cron(0 23 ? * FRI *) solved the problem for me.

    An important and I suppose obvious note when setting cron values: Think about how each value affects the other values you've set. Does each one make logical sense in conjunction with the others?