Skip to content

ScheduleEventSource

Source: src/AWS/Lambda/ScheduleEventSource.ts

Lambda runtime implementation for AWS.Scheduler.consumeSchedule(...) — the “cron handler” DX where a Lambda consumes its own EventBridge Scheduler invocations.

This layer does two things:

  1. At deploy time it creates the backing Schedule targeting the current Lambda function, plus the synthesized execution role that allows EventBridge Scheduler to invoke it.
  2. At runtime it matches incoming Lambda events against the schedule’s typed envelope (isScheduleEvent + the stable route id) and dispatches them to the supplied handler.

Run A Handler Every 5 Minutes

yield* AWS.Scheduler.consumeSchedule(
AWS.Scheduler.every("5 minutes"),
(event) => Effect.log(`fired at ${event.scheduledTime}`),
);

Nightly Cron With An Explicit Route Id

yield* AWS.Scheduler.consumeSchedule(
"NightlyCleanup",
AWS.Scheduler.cron("cron(0 3 * * ? *)"),
(event) => Effect.log(`cleanup ${event.executionId}`),
);