Skip to content

AWS.Scheduler reference

Source: packages/aws/src/Scheduler/CreateSchedule.ts

Runtime binding for scheduler:CreateSchedule, for schedules a deployed runtime creates while it runs: per-user reminders, delayed callbacks, recurring jobs a user turns on.

Bind it to the Queue or Function the schedules deliver to. At deploy time the binding declares the execution role EventBridge Scheduler assumes (allowed to send to that Queue or invoke that Function) and grants the host scheduler:CreateSchedule on the group’s schedules plus iam:PassRole on that role.

The client’s at, every and cron match the deploy-time at(date).toQueue(queue, payload) builders.

CreateSchedule: Creating Schedules At Runtime

Section titled “CreateSchedule: Creating Schedules At Runtime”

Send A Reminder To A Queue In 15 Minutes

const queue = yield* AWS.SQS.Queue("Reminders");
const schedule = yield* AWS.Scheduler.CreateSchedule(queue);
// runtime
yield* schedule.at(new Date(Date.now() + 15 * 60_000), {
name: `reminder-${userId}`,
payload: { userId },
});

Invoke A Function Every Day

const schedule = yield* AWS.Scheduler.CreateSchedule(digestFunction);
// runtime
yield* schedule.every("1 day", {
name: `digest-${userId}`,
payload: { userId },
});

To call the Function the binding runs in back later, use Alchemy.makeCallback with AWS.Scheduler.SchedulerCallbacks instead: the Function routes each job to the handler registered under its name.

Run On A Cron Expression In A Timezone

yield* schedule.cron("cron(0 9 * * ? *)", {
name: `standup-${teamId}`,
timezone: "America/New_York",
payload: { teamId },
});

Create Schedules In A Schedule Group

const group = yield* AWS.Scheduler.ScheduleGroup("Reminders", {});
const schedule = yield* AWS.Scheduler.CreateSchedule(queue, { group });

Send Undeliverable Reminders To A Dead-Letter Queue

const failed = yield* AWS.SQS.Queue("FailedReminders");
const schedule = yield* AWS.Scheduler.CreateSchedule(queue, { deadLetterQueue: failed });

The generated role may send to the dead-letter queue, and every schedule the client writes uses it. kmsKey works the same way for a customer managed key that encrypts the target input.

Use An Existing Execution Role

const schedule = yield* AWS.Scheduler.CreateSchedule(queue, { role });

Send A Raw CreateSchedule Request

// Target.Arn and Target.RoleArn default to the bound target and role
yield* schedule({
Name: `reminder-${userId}`,
ScheduleExpression: "at(2026-01-01T00:00:00)",
ActionAfterCompletion: "DELETE",
Target: { Input: JSON.stringify({ userId }) },
});

Source: packages/aws/src/Scheduler/DeleteSchedule.ts

Runtime binding for scheduler:DeleteSchedule.

Pairs with CreateSchedule for the dynamic-scheduling pattern: a deployed Lambda deletes schedules it minted at runtime (cancel a reminder, clean up a completed one-shot). Optionally scoped to a ScheduleGroup; without one it covers the default group.

DeleteSchedule: Deleting Schedules At Runtime

Section titled “DeleteSchedule: Deleting Schedules At Runtime”

Cancel A Reminder

const deleteSchedule = yield* AWS.Scheduler.DeleteSchedule();
// runtime
yield* deleteSchedule({ Name: `reminder-${userId}` }).pipe(
// already gone — cancellation is idempotent
Effect.catchTag("ResourceNotFoundException", () => Effect.void),
);

Scope Deletion To A Schedule Group

const deleteSchedule = yield* AWS.Scheduler.DeleteSchedule(group);

Source: packages/aws/src/Scheduler/GetSchedule.ts

Runtime binding for scheduler:GetSchedule.

Pairs with CreateSchedule for the dynamic-scheduling pattern: a deployed Lambda inspects schedules it minted at runtime (is the reminder still pending?). Optionally scoped to a ScheduleGroup; without one it covers the default group.

Check A Pending Reminder

const getSchedule = yield* AWS.Scheduler.GetSchedule();
// runtime
const schedule = yield* getSchedule({ Name: `reminder-${userId}` });
console.log(schedule.State, schedule.ScheduleExpression);

Scope Reads To A Schedule Group

const getSchedule = yield* AWS.Scheduler.GetSchedule(group);

Source: packages/aws/src/Scheduler/ListSchedules.ts

Runtime binding for scheduler:ListSchedules.

Pairs with CreateSchedule for the dynamic-scheduling pattern: a deployed Lambda enumerates the schedules it minted at runtime (sweep pending reminders, count outstanding one-shots). Listing is always scoped to the bound ScheduleGroup — or the default group when none is given. Note: IAM evaluates scheduler:ListSchedules against the account-wide schedule/*​/* pattern (not the group), so the binding grants on that pattern while the request’s GroupName filter keeps results group-scoped.

ListSchedules: Listing Schedules At Runtime

Section titled “ListSchedules: Listing Schedules At Runtime”

Sweep Pending Reminders

const listSchedules = yield* AWS.Scheduler.ListSchedules();
// runtime: enumerate this app's runtime-minted reminders
const page = yield* listSchedules({ NamePrefix: "reminder-" });
for (const schedule of page.Schedules) {
console.log(schedule.Name, schedule.State);
}

Scope Listing To A Schedule Group

const listSchedules = yield* AWS.Scheduler.ListSchedules(group);

Source: packages/aws/src/Scheduler/Schedule.ts

An EventBridge Scheduler schedule.

Schedule is the canonical time-based delivery primitive. High-level helpers like every, cron, and at can synthesize the target role and scheduler target configuration on top of this resource.

const schedule = yield* Schedule("HourlyJob", {
scheduleExpression: "rate(1 hour)",
target: {
Arn: fn.functionArn,
RoleArn: role.roleArn,
},
flexibleTimeWindow: {
Mode: "OFF",
},
});

Source: packages/aws/src/Scheduler/ScheduleEventSource.ts

Deploy-time half of consumeSchedule: synthesize the execution role that lets EventBridge Scheduler invoke the host Function and create the backing Schedule whose Input template carries the typed event envelope.

Source: packages/aws/src/Scheduler/ScheduleGroup.ts

An EventBridge Scheduler schedule group.

Schedule groups provide a namespace for schedules so higher-level helpers can organize recurring jobs separately from one-shot or operational schedules.

const group = yield* ScheduleGroup("Operations", {
tags: {
domain: "ops",
},
});

Source: packages/aws/src/Scheduler/SchedulerCallbacks.ts

Durable callbacks on EventBridge Scheduler, for a Lambda Function.

Provide it to a Function to use Alchemy.makeCallback. Register each callback while the Function initializes; the Function routes every scheduled invocation to the handler registered under its name. schedule(id, ...) creates a one-time schedule that invokes the Function itself, cancel(id) deletes it, and getStatus(id) reads it.

At deploy time the layer declares a schedule group for the Function, a role EventBridge Scheduler assumes to invoke it, and grants the Function scheduler:CreateSchedule, UpdateSchedule, DeleteSchedule and GetSchedule on that group plus iam:PassRole on the role. Destroying the stack deletes the group and every pending job in it.

SchedulerCallbacks: Calling A Function Back Later

Section titled “SchedulerCallbacks: Calling A Function Back Later”
export default Orders.make(
{ main: import.meta.url, functionUrl: true },
Effect.gen(function* () {
const onExpire = yield* Alchemy.makeCallback(
"expire",
Effect.fn(function* ({ orderId }: { orderId: string }) {
yield* expireOrder(orderId).pipe(
Effect.retry({ schedule: Schedule.exponential("1 second"), times: 3 }),
Effect.orDie,
);
}),
);
return {
fetch: Effect.gen(function* () {
const orderId = yield* placeOrder;
// the same ID replaces a pending job; onExpire.cancel(orderId) removes it
yield* onExpire.schedule(orderId, { after: "1 hour", payload: { orderId } });
return yield* HttpServerResponse.json({ orderId });
}).pipe(Effect.orDie),
};
}).pipe(Effect.provide(AWS.Scheduler.SchedulerCallbacks())),
);

Scheduler invokes the Function asynchronously, and retries the invoke itself (throttling, an unavailable Function) for up to 24 hours. A handler that dies (a defect, a timeout, running out of memory) fails the invocation, which Lambda retries twice.

Send Every Failed Callback To A Queue

impl.pipe(
Effect.provide(
AWS.Scheduler.SchedulerCallbacks({ deadLetterQueue: AWS.SQS.Queue("FailedCallbacks") }),
),
);

The queue is Scheduler’s dead-letter queue for invokes it gives up on and the Function’s OnFailure destination for handlers that keep dying, so both kinds of failure end up in one place. Lambda keeps one failure destination per Function, so it applies to every callback the Function registers. Set eventInvokeConfig.maximumRetryAttempts on the Function to change how often Lambda retries.

Encrypt Payloads With Your Own Key

impl.pipe(
Effect.provide(AWS.Scheduler.SchedulerCallbacks({ kmsKey: AWS.KMS.Key("CallbackKey", {}) })),
);

A recurring job (every or cron) is one schedule that moves from run to run. While a run is delivered it waits as that run’s retry, from a minute doubling to an hour, so a handler that dies is delivered again until it succeeds; then it moves to the next run. Lambda’s own retries of a recurring run are skipped. Its runs keep Scheduler’s precision of about a minute, whatever the interval.

Delivery is at least once, so handlers must be idempotent. A job runs at its time or up to about a minute later. Payloads are JSON, and a job must fit in Scheduler’s 8 KB target input. Scheduling and cancelling are API calls, not part of a transaction. A successful delivery deletes its job unless the job was replaced while it ran; the check and the delete are two calls, so a replacement made between them can be lost. A job that runs out of retries keeps its spent schedule in the group until the stack is destroyed. A callback invokes the Function’s unqualified ARN, even when the Function routes through an alias.

Source: packages/aws/src/Scheduler/UpdateSchedule.ts

Runtime binding for scheduler:UpdateSchedule.

Pairs with CreateSchedule: a deployed runtime reschedules or pauses schedules it created (push a reminder back, disable a recurring job). UpdateSchedule is a full PUT — unspecified fields are reset to their defaults — so at, every and cron send the complete configuration.

Like CreateSchedule, bind it to the Queue or Function the schedules deliver to. It declares the same execution role and grants the host scheduler:UpdateSchedule on the group’s schedules plus iam:PassRole on that role.

UpdateSchedule: Updating Schedules At Runtime

Section titled “UpdateSchedule: Updating Schedules At Runtime”

Push A Reminder Back A Day

const reschedule = yield* AWS.Scheduler.UpdateSchedule(queue);
// runtime
yield* reschedule.at(new Date(Date.now() + 24 * 60 * 60_000), {
name: `reminder-${userId}`,
payload: { userId },
});

Pause A Recurring Schedule

yield* reschedule.every("1 day", {
name: `digest-${userId}`,
state: "DISABLED",
payload: { userId },
});

Update Schedules In A Schedule Group

const reschedule = yield* AWS.Scheduler.UpdateSchedule(queue, { group });