Search code examples
aws-lambdaserverless-frameworkserverless

Getting Parameter ScheduleExpression is not valid on aws lambda?


I want to schedule a job to run on Thursday every week but when I used this I am getting an error.

Cron Expression I am using:

"Events": {
    "UsedForCorn": {
        "Type": "Schedule",
        "Properties": {
            "Schedule": "corn(0 20 ? * 5 *)"
        }
    }
}

I am getting the following error:

CREATE_FAILED Parameter ScheduleExpression is not valid. (Service: AmazonCloudWatchEvents; Status Code: 400; Error Code: ValidationException; Request ID: f9186d09-3e27-43db-a58a-5f5288deaa56; Proxy: null)

Solution

  • You have a typo in your Schedule value. You used corn instead of cron.

    "Events": {
        "UsedForCorn": {
            "Type": "Schedule",
            "Properties": {
                "Schedule": "cron(0 20 ? * 5 *)"
            }
        }
    }