meal-order-manager/terraform/scheduler.tf
Adam Moussa cc506f3c1f
Some checks are pending
Deploy API / Deploy API to dev (push) Waiting to run
Deploy API / Deploy API to prod (push) Waiting to run
feat(menu): publish the weekly menu from the job worker (PLAT-229) (#219)
* feat(menu): publish the weekly menu from the job worker

Monday publish parses the catalog embedded in the Redefine menu page and runs on the Fargate worker, so the GitHub Actions scrape cron can go away.

* fix(menu): address review feedback

Use the form deadline in the Monday Slack post, and compare that message exactly so CodeQL does not treat the test as URL sanitization.
2026-09-25 22:10:24 +00:00

50 lines
1.5 KiB
HCL

# EventBridge Scheduler in Eastern time. Replaces dual EST/EDT Lambda crons.
locals {
job_schedules = {
close = {
description = "Close form Thursday 11:59pm Eastern"
schedule = "cron(59 23 ? * THU *)"
event = "close"
}
reminder = {
description = "DM reminders Thursday 10am Eastern"
schedule = "cron(0 10 ? * THU *)"
event = "reminder"
}
sync-roster = {
description = "Sync roster Monday 6:55am Eastern, before menu publish"
schedule = "cron(55 6 ? * MON *)"
event = "sync_roster"
}
publish-menu = {
description = "Publish the weekly menu Monday 7:30am Eastern"
schedule = "cron(30 7 ? * MON *)"
event = "publish_menu"
}
}
}
resource "aws_scheduler_schedule_group" "jobs" {
name = local.project
}
resource "aws_scheduler_schedule" "jobs" {
for_each = local.job_schedules
name = "${local.project}-${each.key}"
group_name = aws_scheduler_schedule_group.jobs.name
description = each.value.description
schedule_expression = each.value.schedule
schedule_expression_timezone = "America/New_York"
state = local.is_prod ? "ENABLED" : "DISABLED"
flexible_time_window {
mode = "OFF"
}
target {
arn = aws_sqs_queue.jobs.arn
role_arn = aws_iam_role.scheduler.arn
input = jsonencode({ event = each.value.event })
}
}