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

fix(scheduler-alpha): deprecate Group in favour of ScheduleGroup #33678

Merged
merged 7 commits into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions packages/@aws-cdk/aws-scheduler-alpha/README.md
Original file line number Diff line number Diff line change
@@ -100,22 +100,22 @@ const oneTimeSchedule = new Schedule(this, 'Schedule', {
Your AWS account comes with a default scheduler group. You can access the default group in CDK with:

```ts
const defaultGroup = Group.fromDefaultGroup(this, "DefaultGroup");
const defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultGroup");
```

You can add a schedule to a custom scheduling group managed by you. If a custom group is not specified, the schedule is added to the default group.

```ts
declare const target: targets.LambdaInvoke;

const group = new Group(this, "Group", {
groupName: "MyGroup",
const scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", {
scheduleGroupName: "MyScheduleGroup",
});

new Schedule(this, 'Schedule', {
schedule: ScheduleExpression.rate(Duration.minutes(10)),
target,
group,
scheduleGroup,
});
```

@@ -300,25 +300,25 @@ new cloudwatch.Alarm(this, 'SchedulesErrorAlarm', {
});
```

### Metrics for a Group
### Metrics for a Schedule Group

To view metrics for a specific group you can use methods on class `Group`:
To view metrics for a specific group you can use methods on class `ScheduleGroup`:

```ts
const group = new Group(this, "Group", {
groupName: "MyGroup",
const scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", {
scheduleGroupName: "MyScheduleGroup",
});

new cloudwatch.Alarm(this, 'MyGroupErrorAlarm', {
metric: group.metricTargetErrors(),
metric: scheduleGroup.metricTargetErrors(),
evaluationPeriods: 1,
threshold: 0
});

// Or use default group
const defaultGroup = Group.fromDefaultGroup(this, "DefaultGroup");
new cloudwatch.Alarm(this, 'DefaultGroupErrorAlarm', {
metric: defaultGroup.metricTargetErrors(),
const defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultScheduleGroup");
new cloudwatch.Alarm(this, 'DefaultScheduleGroupErrorAlarm', {
metric: defaultScheduleGroup.metricTargetErrors(),
evaluationPeriods: 1,
threshold: 0
});
17 changes: 2 additions & 15 deletions packages/@aws-cdk/aws-scheduler-alpha/awslint.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
{
"exclude": [
"construct-ctor-props-optional:@aws-cdk/aws-scheduler-alpha.Group",
"props-physical-name:@aws-cdk/aws-scheduler-alpha.GroupProps",
"from-method:@aws-cdk/aws-scheduler-alpha.Schedule",
"attribute-tag:@aws-cdk/aws-scheduler-alpha.Schedule.scheduleArn",
"attribute-tag:@aws-cdk/aws-scheduler-alpha.Schedule.scheduleName",
"attribute-tag:@aws-cdk/aws-scheduler-alpha.Schedule.scheduleGroup",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this exemption as scheduleGroup is not an attribute of Schedule

"docs-public-apis:@aws-cdk/aws-scheduler-alpha.ContextAttribute.name",
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.Group",
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.GroupProps",
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.IGroup",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleProps.targetOverrides",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.deadLetterConfig",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.ecsParameters",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.eventBridgeParameters",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.input",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.kinesisParameters",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.retryPolicy",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.sageMakerPipelineParameters",
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.sqsParameters",
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.ScheduleTargetProps"
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.IGroup"
]
}
10 changes: 7 additions & 3 deletions packages/@aws-cdk/aws-scheduler-alpha/lib/group.ts
Original file line number Diff line number Diff line change
@@ -290,6 +290,7 @@ abstract class GroupBase extends Resource implements IGroup {
}
/**
* @resource AWS::Scheduler::ScheduleGroup
* @deprecated Use `ScheduleGroup` instead. `Group` will be removed when this module is stabilized.
*/
export class Group extends GroupBase {
/**
@@ -298,6 +299,7 @@ export class Group extends GroupBase {
* @param scope construct scope
* @param id construct id
* @param groupArn the ARN of the group to import (e.g. `arn:aws:scheduler:region:account-id:schedule-group/group-name`)
* @deprecated Use `ScheduleGroup.fromScheduleGroupArn()` instead.
*/
public static fromGroupArn(scope: Construct, id: string, groupArn: string): IGroup {
const arnComponents = Stack.of(scope).splitArn(groupArn, ArnFormat.SLASH_RESOURCE_NAME);
@@ -314,6 +316,7 @@ export class Group extends GroupBase {
*
* @param scope construct scope
* @param id construct id
* @deprecated Use `ScheduleGroup.fromDefaultScheduleGroup()` instead.
*/
public static fromDefaultGroup(scope: Construct, id: string): IGroup {
return Group.fromGroupName(scope, id, 'default');
@@ -325,6 +328,7 @@ export class Group extends GroupBase {
* @param scope construct scope
* @param id construct id
* @param groupName the name of the existing group to import
* @deprecated Use `ScheduleGroup.fromScheduleGroupName()` instead.
*/
public static fromGroupName(scope: Construct, id: string, groupName: string): IGroup {
const groupArn = Stack.of(scope).formatArn({
@@ -338,12 +342,12 @@ export class Group extends GroupBase {
public readonly groupName: string;
public readonly groupArn: string;

public constructor(scope: Construct, id: string, props: GroupProps) {
public constructor(scope: Construct, id: string, props?: GroupProps) {
super(scope, id);
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.groupName = props.groupName ?? Names.uniqueResourceName(this, {
this.groupName = props?.groupName ?? Names.uniqueResourceName(this, {
maxLength: 64,
separator: '-',
});
@@ -352,7 +356,7 @@ export class Group extends GroupBase {
name: this.groupName,
});

group.applyRemovalPolicy(props.removalPolicy);
group.applyRemovalPolicy(props?.removalPolicy);

this.groupArn = this.getResourceArnAttribute(group.attrArn, {
service: 'scheduler',
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-scheduler-alpha/lib/index.ts
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ export * from './input';
export * from './schedule';
export * from './group';
export * from './target';
export * from './schedule-group';
Loading
Oops, something went wrong.