Repository navigation
Description
Submitting a pattern for migrating cron on a VM to Amazon EventBridge Scheduler, and asking one structural question before you spend review time on it.
Folder: eventbridge-scheduler-cron-migration/python/sam
Services: Amazon EventBridge Scheduler, AWS Lambda, Amazon DynamoDB, Amazon CloudWatch
Language / framework: Python / AWS SAM
What it does
An import script reads an existing crontab, converts each line into a Scheduler cron expression, and creates one schedule per entry targeting a single Lambda dispatcher. The dispatcher records each run in a DynamoDB table keyed on the scheduled window, a CloudWatch alarm with TreatMissingData: breaching fires when a job does not report completion, and a catch-up function idempotently replays windows missed while no schedule was running, such as during a deployment.
The question: new family, or a variant of an existing one?
PUBLISHING.md asks me to add a variant to an existing family when the services match, so I want to check this rather than guess.
I went through the 65 pattern folders with schedule or scheduler in the name. The closest are:
| Pattern | What it covers |
|---|---|
eventbridge-schedule-to-lambda (10 variants) |
one schedule invoking one function |
eventbridge-schedule-to-lambda-dlq/python/sam |
the same, with dead-letter queues |
eventbridge-schedule-lambda-to-dynamodb/dotnet/cdk |
closest by services: Scheduler, Lambda and DynamoDB |
lambda-durable-eventbridge-cron (python/sam, nodejs/sam) |
a durable function on a cron schedule |
lambda-durable-scheduled-tasks/sam |
a multi-day workflow with scheduled waits |
All of them wire up a schedule and invoke a target. Searching the repo for crontab, catch-up and run-history returns no pattern content, so importing an existing crontab, keeping an execution record, alarming on a missing completion and replaying a missed window are not covered today.
I proposed a new family because the pattern is about the migration rather than the wiring, and because the folder name is what somebody searching for how to replace cron is likely to find. But eventbridge-schedule-lambda-to-dynamodb is the closest service match and currently has only a dotnet/cdk variant, so folding this in as its python/sam variant is a reasonable alternative.
Happy to go either way — tell me which you prefer and I will move it in the PR. I would rather rename the folder now than after review.
Scope
Four services and two Lambda functions. I kept it deliberately smaller than the idea allows: one dispatcher with the example jobs as functions inside it rather than one Lambda function per job, and the crontab importer as a local script rather than deployed infrastructure. If it still reads as closer to a utility than a pattern, I would rather hear that now too.
Checks
node _scripts/check-folder.js, node _scripts/validate.js, sam validate --lint and sam build all pass. Deployed and tested in my own account in us-east-1 and torn down: the recurring schedule fired on its own inside the documented 60 second window, run history recorded the start and the completion, replaying a completed window returned SKIPPED, the alarm reached ALARM on a missing completion, and catch-up resolved a schedule defined in America/New_York to the right UTC windows. The crontab conversion has a known-answer unit test suite covering the field count, the day-of-week shift and each refusal.
Two findings from testing are commented in the template in case they are useful elsewhere: the Scheduler execution role's aws:SourceArn has to name the schedule group rather than schedule/<group>/*, or CreateSchedule rejects the role; and scheduler:ListSchedules is authorised against schedule/*/* even when the call filters by GroupName, so it cannot be scoped to a single group.
Activity