Skip to content

Commit 4d8eae9

Browse files
authoredMar 5, 2025
fix(scheduler-alpha): deprecate Group in favour of ScheduleGroup (#33678)
### Issue # (if applicable) n/a ### Reason for this change The `awslint` rules enforce naming to be consistent with CloudFormation resources. In this case, the CFN resource is `AWS::Scheduler::ScheduleGroup` but the construct was named `Group` when it should be `ScheduleGroup`. When this module is stabilized, `Group` will be completely removed. ### Description of changes - Mark `Group` and related methods as deprecated. Deprecation - Introduce new class `ScheduleGroup` (duplicate of Group, just renamed) - Addressed most `awslint` exemptions in the module - Update any logic referencing `group` to reference `scheduleGroup` - Updated README examples ### Describe any new or updated permissions being added n/a ### Description of how you validated changes Updated unit tests ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 4bc151b commit 4d8eae9

File tree

12 files changed

+826
-58
lines changed

12 files changed

+826
-58
lines changed
 

‎packages/@aws-cdk/aws-scheduler-alpha/README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,22 @@ const oneTimeSchedule = new Schedule(this, 'Schedule', {
100100
Your AWS account comes with a default scheduler group. You can access the default group in CDK with:
101101

102102
```ts
103-
const defaultGroup = Group.fromDefaultGroup(this, "DefaultGroup");
103+
const defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultGroup");
104104
```
105105

106106
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.
107107

108108
```ts
109109
declare const target: targets.LambdaInvoke;
110110

111-
const group = new Group(this, "Group", {
112-
groupName: "MyGroup",
111+
const scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", {
112+
scheduleGroupName: "MyScheduleGroup",
113113
});
114114

115115
new Schedule(this, 'Schedule', {
116116
schedule: ScheduleExpression.rate(Duration.minutes(10)),
117117
target,
118-
group,
118+
scheduleGroup,
119119
});
120120
```
121121

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

303-
### Metrics for a Group
303+
### Metrics for a Schedule Group
304304

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

307307
```ts
308-
const group = new Group(this, "Group", {
309-
groupName: "MyGroup",
308+
const scheduleGroup = new ScheduleGroup(this, "ScheduleGroup", {
309+
scheduleGroupName: "MyScheduleGroup",
310310
});
311311

312312
new cloudwatch.Alarm(this, 'MyGroupErrorAlarm', {
313-
metric: group.metricTargetErrors(),
313+
metric: scheduleGroup.metricTargetErrors(),
314314
evaluationPeriods: 1,
315315
threshold: 0
316316
});
317317

318318
// Or use default group
319-
const defaultGroup = Group.fromDefaultGroup(this, "DefaultGroup");
320-
new cloudwatch.Alarm(this, 'DefaultGroupErrorAlarm', {
321-
metric: defaultGroup.metricTargetErrors(),
319+
const defaultScheduleGroup = ScheduleGroup.fromDefaultScheduleGroup(this, "DefaultScheduleGroup");
320+
new cloudwatch.Alarm(this, 'DefaultScheduleGroupErrorAlarm', {
321+
metric: defaultScheduleGroup.metricTargetErrors(),
322322
evaluationPeriods: 1,
323323
threshold: 0
324324
});
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
{
22
"exclude": [
3-
"construct-ctor-props-optional:@aws-cdk/aws-scheduler-alpha.Group",
43
"props-physical-name:@aws-cdk/aws-scheduler-alpha.GroupProps",
5-
"from-method:@aws-cdk/aws-scheduler-alpha.Schedule",
6-
"attribute-tag:@aws-cdk/aws-scheduler-alpha.Schedule.scheduleArn",
7-
"attribute-tag:@aws-cdk/aws-scheduler-alpha.Schedule.scheduleName",
4+
"attribute-tag:@aws-cdk/aws-scheduler-alpha.Schedule.scheduleGroup",
85
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.ContextAttribute.name",
96
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.Group",
107
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.GroupProps",
11-
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.IGroup",
12-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleProps.targetOverrides",
13-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.deadLetterConfig",
14-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.ecsParameters",
15-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.eventBridgeParameters",
16-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.input",
17-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.kinesisParameters",
18-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.retryPolicy",
19-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.sageMakerPipelineParameters",
20-
"props-default-doc:@aws-cdk/aws-scheduler-alpha.ScheduleTargetConfig.sqsParameters",
21-
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.ScheduleTargetProps"
8+
"docs-public-apis:@aws-cdk/aws-scheduler-alpha.IGroup"
229
]
2310
}

‎packages/@aws-cdk/aws-scheduler-alpha/lib/group.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ abstract class GroupBase extends Resource implements IGroup {
290290
}
291291
/**
292292
* @resource AWS::Scheduler::ScheduleGroup
293+
* @deprecated Use `ScheduleGroup` instead. `Group` will be removed when this module is stabilized.
293294
*/
294295
export class Group extends GroupBase {
295296
/**
@@ -298,6 +299,7 @@ export class Group extends GroupBase {
298299
* @param scope construct scope
299300
* @param id construct id
300301
* @param groupArn the ARN of the group to import (e.g. `arn:aws:scheduler:region:account-id:schedule-group/group-name`)
302+
* @deprecated Use `ScheduleGroup.fromScheduleGroupArn()` instead.
301303
*/
302304
public static fromGroupArn(scope: Construct, id: string, groupArn: string): IGroup {
303305
const arnComponents = Stack.of(scope).splitArn(groupArn, ArnFormat.SLASH_RESOURCE_NAME);
@@ -314,6 +316,7 @@ export class Group extends GroupBase {
314316
*
315317
* @param scope construct scope
316318
* @param id construct id
319+
* @deprecated Use `ScheduleGroup.fromDefaultScheduleGroup()` instead.
317320
*/
318321
public static fromDefaultGroup(scope: Construct, id: string): IGroup {
319322
return Group.fromGroupName(scope, id, 'default');
@@ -325,6 +328,7 @@ export class Group extends GroupBase {
325328
* @param scope construct scope
326329
* @param id construct id
327330
* @param groupName the name of the existing group to import
331+
* @deprecated Use `ScheduleGroup.fromScheduleGroupName()` instead.
328332
*/
329333
public static fromGroupName(scope: Construct, id: string, groupName: string): IGroup {
330334
const groupArn = Stack.of(scope).formatArn({
@@ -338,12 +342,12 @@ export class Group extends GroupBase {
338342
public readonly groupName: string;
339343
public readonly groupArn: string;
340344

341-
public constructor(scope: Construct, id: string, props: GroupProps) {
345+
public constructor(scope: Construct, id: string, props?: GroupProps) {
342346
super(scope, id);
343347
// Enhanced CDK Analytics Telemetry
344348
addConstructMetadata(this, props);
345349

346-
this.groupName = props.groupName ?? Names.uniqueResourceName(this, {
350+
this.groupName = props?.groupName ?? Names.uniqueResourceName(this, {
347351
maxLength: 64,
348352
separator: '-',
349353
});
@@ -352,7 +356,7 @@ export class Group extends GroupBase {
352356
name: this.groupName,
353357
});
354358

355-
group.applyRemovalPolicy(props.removalPolicy);
359+
group.applyRemovalPolicy(props?.removalPolicy);
356360

357361
this.groupArn = this.getResourceArnAttribute(group.attrArn, {
358362
service: 'scheduler',

‎packages/@aws-cdk/aws-scheduler-alpha/lib/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './input';
33
export * from './schedule';
44
export * from './group';
55
export * from './target';
6+
export * from './schedule-group';

0 commit comments

Comments
 (0)
Failed to load comments.