The TF plan shows the following:
# aws_scheduler_schedule.gh_runners_ubuntu_start["gh_runner_ubuntu"] will be created
+ resource "aws_scheduler_schedule" "gh_runners_ubuntu_start" {
+ arn = (known after apply)
+ group_name = (known after apply)
+ id = (known after apply)
+ name = "gh_runners_ubuntu_start-ormos-runner"
+ name_prefix = (known after apply)
+ schedule_expression = "cron(0 23 * * *)"
+ schedule_expression_timezone = "UTC"
+ state = "ENABLED"
+ flexible_time_window {
+ mode = "OFF"
}
+ target {
+ arn = "arn:aws:scheduler:::aws-sdk:ec2:startInstances"
+ input = jsonencode(
{
+ InstanceIds = [
+ "i-xxxxxxxxxxxxxxxxx",
]
}
)
+ role_arn = "arn:aws:iam::12345678:role/gh_runners_ubuntu_scheduler_role-runner"
}
}
Creation fails with:
ValidationException: Invalid Schedule Expression cron(0 23 * * *).
Any ideas?
2
Answers
Check the docs for AWS Cron Syntax. You have 5 values but they use 6. It differs than standard Linux Cron Syntax
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions
Edit: I believe my suggestion is incorrect and you should look at the one provided by Chris
The terraform docs provide a link to the AWS docs about the schedule expression
If you reach the cron expression docs it tells you the format is
where the year part is optional. You are passing 5 parameters to cron expression which is correct. However if you read the docs it states
You are using
*
in both the day-of-mont field and the day-of-week field which is not allowed. Thats why you get invalid expression. you should instead set it as