Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scheduler): ScheduleGroup #26196

Merged
merged 10 commits into from
Jul 24, 2023
51 changes: 49 additions & 2 deletions packages/@aws-cdk/aws-scheduler-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ TODO: Schedule is not yet fully implemented. See section in [L2 Event Bridge Sch
Only an L2 class is created that wraps the L1 class and handles the following properties:

- schedule
- schedule group
- target (only LambdaInvoke is supported for now)
- flexibleTimeWindow will be set to `{ mode: 'OFF' }`

Expand Down Expand Up @@ -97,7 +98,31 @@ const oneTimeSchedule = new Schedule(this, 'Schedule', {

### Grouping Schedules

TODO: Group is not yet implemented. See section in [L2 Event Bridge Scheduler RFC](https://github.com/aws/aws-cdk-rfcs/blob/master/text/0474-event-bridge-scheduler-l2.md)
Your AWS account comes with a default scheduler group. You can access default group in CDK with:

```text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these examples can be in ts now? Since they should be fully implemented right. Then you will also have to double check with yarn rosetta:extract --strict or else the PR build may fail :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now, good catch

const defaultGroup = Group.fromDefaultGroup(this, "DefaultGroup");
```

If not specified a schedule is added to the default group. However, uou can also add the schedule to a custom scheduling group managed by you:
kaizencc marked this conversation as resolved.
Show resolved Hide resolved

```text
const group = new Group(this, "Group", {
groupName: "MyGroup",
});

const target = new targets.LambdaInvoke(props.func, {
input: ScheduleTargetInput.fromObject({
"payload": "useful",
}),
});

new Schedule(this, 'Schedule', {
scheduleExpression: ScheduleExpression.rate(Duration.minutes(10)),
target,
group
kaizencc marked this conversation as resolved.
Show resolved Hide resolved
});
```

## Scheduler Targets

Expand Down Expand Up @@ -164,4 +189,26 @@ TODO: Not yet implemented. See section in [L2 Event Bridge Scheduler RFC](https:

### Metrics for a Group

TODO: Not yet implemented. See section in [L2 Event Bridge Scheduler RFC](https://github.com/aws/aws-cdk-rfcs/blob/master/text/0474-event-bridge-scheduler-l2.md)
To view metrics for a specific group you can use methods on class `Group`:

```text
const group = new Group(this, "Group", {
groupName: "MyGroup"
});

new Alarm(this, 'MyGroupErrorAlarm', {
metric: group.metricAllErrors(),
threshold: 0
});

// Or use default group
const defaultGroup = Group.fromDefaultGroup(this, "DefaultGroup");
new Alarm(this, 'DefaultGroupErrorAlarm', {
metric: defaultGroup.metricAllErrors(),
threshold: 0
});
kaizencc marked this conversation as resolved.
Show resolved Hide resolved
```

See full list of metrics and their description at
[Monitoring Using CloudWatch Metrics](https://docs.aws.amazon.com/scheduler/latest/UserGuide/monitoring-cloudwatch.html)
in the *AWS Event Bridge Scheduler User Guide*.