From 9f66b237c2b41462e5ac01579f6fed709a3bc1e1 Mon Sep 17 00:00:00 2001 From: MURAKAMI Masahiko Date: Mon, 6 Oct 2025 23:53:24 +0900 Subject: [PATCH 1/2] feat(function): update EventBridge reference and add timezone support for function schedules --- .../functions/scheduling-functions/index.mdx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx b/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx index 27f3cd59e25..826aeb48163 100644 --- a/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx +++ b/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx @@ -46,7 +46,7 @@ export const weeklyDigest = defineFunction({ }); ``` -Function schedules are powered by [Amazon EventBridge rules](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-rules.html), and can be leveraged to address use cases such as: +Function schedules are powered by [Amazon EventBridge Scheduler](https://docs.aws.amazon.com/eventbridge/latest/userguide/using-eventbridge-scheduler.html), and can be leveraged to address use cases such as: - generating a "front page" of top-performing posts - generating a weekly digest of top-performing posts @@ -155,3 +155,21 @@ export const remindMe = defineFunction({ ] }) ``` + +## Timezone + +Schedules can be set with a timezone. + +```ts title="amplify/jobs/monthly-report/resource.ts" +import { defineFunction } from "@aws-amplify/backend"; + +export const remindMe = defineFunction({ + name: "monthly-report", + schedule: [ + // 1st day of every month at 0am with Asia/Tokyo + { cron: "0 0 1 * * *", timezone: "Asia/Tokyo" }, + // the first of the month at midnight with America/New_York + { rate: "every month", timezone: "America/New_York" }, + ] +}) +``` From 67ffc8ca61677205ab4d70285461f8edcd1dbbbc Mon Sep 17 00:00:00 2001 From: MURAKAMI Masahiko Date: Tue, 7 Oct 2025 08:27:07 +0900 Subject: [PATCH 2/2] fix: correct cron syntax for monthly report schedule and update function name --- .../functions/scheduling-functions/index.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx b/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx index 826aeb48163..ea9997cffeb 100644 --- a/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx +++ b/src/pages/[platform]/build-a-backend/functions/scheduling-functions/index.mdx @@ -163,13 +163,13 @@ Schedules can be set with a timezone. ```ts title="amplify/jobs/monthly-report/resource.ts" import { defineFunction } from "@aws-amplify/backend"; -export const remindMe = defineFunction({ +export const monthlyReport = defineFunction({ name: "monthly-report", schedule: [ // 1st day of every month at 0am with Asia/Tokyo - { cron: "0 0 1 * * *", timezone: "Asia/Tokyo" }, + { cron: "0 0 1 * ? *", timezone: "Asia/Tokyo" }, // the first of the month at midnight with America/New_York { rate: "every month", timezone: "America/New_York" }, ] -}) +}); ```