diff --git a/libs/wingsdk/src/target-awscdk/schedule.ts b/libs/wingsdk/src/target-awscdk/schedule.ts index 5a149527eea..55d4bc7f700 100644 --- a/libs/wingsdk/src/target-awscdk/schedule.ts +++ b/libs/wingsdk/src/target-awscdk/schedule.ts @@ -38,11 +38,15 @@ export class Schedule extends cloud.Schedule { let cronOpt: { [k: string]: string } = { minute: cronArr[0], hour: cronArr[1], - day: cronArr[2], month: cronArr[3], - weekDay: cronArr[4], year: "*", }; + if (cronArr[2] !== "?") { + cronOpt.day = cronArr[2]; + } + if (cronArr[4] !== "?") { + cronOpt.weekDay = cronArr[4]; + } this.scheduleExpression = EventSchedule.cron(cronOpt); } else { diff --git a/libs/wingsdk/test/target-awscdk/schedule.test.ts b/libs/wingsdk/test/target-awscdk/schedule.test.ts index 0165dc9b50d..52138097614 100644 --- a/libs/wingsdk/test/target-awscdk/schedule.test.ts +++ b/libs/wingsdk/test/target-awscdk/schedule.test.ts @@ -152,4 +152,4 @@ test("cron with Day-of-month and Day-of-week setting with *", () => { ).toThrow( "cannot use * in both the Day-of-month and Day-of-week fields. If you use it in one, you must use ? in the other" ); -}); \ No newline at end of file +});