-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scheduler): flexible time windows (#28098)
This PR adds support for configuring flexible time windows. ## Description Currently, users cannot configure the `flexibleTimeWindow` feature in the Scheduler construct. This feature enhances flexibility and reliability, allowing tasks to be invoked within a defined time window. https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-schedule-flexible-time-windows.html CloudFormation allows users to take advantage of this feature as follows. With this template, it will invokes the target within 10 minutes after the scheduled time. ```yaml Resources: Schedule: Type: AWS::Scheduler::Schedule Properties: FlexibleTimeWindow: Mode: "FLEXIBLE" # or "OFF" MaximumWindowInMinutes: 10 # between 1 and 1440 Name: "sample-schedule" ScheduleExpression: "cron(0 9 * * ? *)" State: "ENABLED" Target: Arn: hoge RoleArn: hoge ``` ## Changes ### add Enum indicating flexible time window mode Currently there are only two modes, FLEXIBLE and OFF, so there is no problem using boolean instead of enum. But I think it's better to use Enum to prepare for future expansion. https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-flexibletimewindow.html ### add property to `ScheduleProps` interface `flexibleTimeWindowMode` property defaults to `OFF` to avoid a breaking change. ```ts interface ScheduleProps { // .... /** * Determines whether the schedule is invoked within a flexible time window. * * @see https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-schedule-flexible-time-windows.html * * @default - FlexibleTimeWindowMode.OFF */ readonly flexibleTimeWindowMode?: FlexibleTimeWindowMode; /** * The maximum time window during which the schedule can be invoked. * * @default - Required if flexibleTimeWindowMode is FLEXIBLE. */ readonly maximumWindowInMinutes?: Duration; } ``` ### set the added property to `CfnSchedule` construct Basically, just set the values as documented, but with the following validations. - If `flexibleTimeWindowMode` is `FLEXIBLE` - `maximumWindowInMinutes` must be specified - `maximumWindowInMinutes` must be set from 1 to 1440 minutes https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-flexibletimewindow.html In addition, I added some unit tests and integ-tests. ### others - fixed typo in README - `customizeable` => `customizable` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
7c62d68
commit 6554e48
Showing
9 changed files
with
227 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ws-scheduler-alpha/test/integ.schedule.js.snapshot/aws-cdk-scheduler-schedule.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/manifest.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/tree.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters