Skip to content

Commit 06dcb4d

Browse files
authored
2 parents 1379fd1 + aaf17e5 commit 06dcb4d

File tree

8 files changed

+104
-78
lines changed

8 files changed

+104
-78
lines changed

CHANGELOG.v2.alpha.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.229.1-alpha.0](https://github.com/aws/aws-cdk/compare/v2.229.0-alpha.0...v2.229.1-alpha.0) (2025-11-25)
6+
57
## [2.229.0-alpha.0](https://github.com/aws/aws-cdk/compare/v2.228.0-alpha.0...v2.229.0-alpha.0) (2025-11-24)
68

79

CHANGELOG.v2.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [2.229.1](https://github.com/aws/aws-cdk/compare/v2.229.0...v2.229.1) (2025-11-25)
6+
7+
8+
### Bug Fixes
9+
10+
* **scheduler:** wrong ARN generated in `ScheduleGroup.grant*` methods ([#36175](https://github.com/aws/aws-cdk/issues/36175)) ([ca9fbdd](https://github.com/aws/aws-cdk/commit/ca9fbdd4c7d9551e18abe4967f0b8649302aaa56))
11+
512
## [2.229.0](https://github.com/aws/aws-cdk/compare/v2.228.0...v2.229.0) (2025-11-24)
613

714

packages/aws-cdk-lib/aws-scheduler/grants.json

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export * from './scheduler.generated';
2-
export * from './scheduler-grants.generated';
32
export * from './schedule-expression';
43
export * from './input';
54
export * from './schedule';
65
export * from './target';
76
export * from './schedule-group';
7+
export * from './schedule-group-grants';
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* eslint-disable @stylistic/max-len, eol-last */
2+
import * as scheduler from './scheduler.generated';
3+
import * as iam from '../../aws-iam';
4+
import { Arn, Aws } from '../../core';
5+
6+
/**
7+
* Properties for ScheduleGroupGrants
8+
*/
9+
interface ScheduleGroupGrantsProps {
10+
/**
11+
* The resource on which actions will be allowed
12+
*/
13+
readonly resource: scheduler.IScheduleGroupRef;
14+
}
15+
16+
/**
17+
* Collection of grant methods for a IScheduleGroupRef
18+
*/
19+
export class ScheduleGroupGrants {
20+
/**
21+
* Creates grants for ScheduleGroupGrants
22+
*/
23+
public static fromScheduleGroup(resource: scheduler.IScheduleGroupRef): ScheduleGroupGrants {
24+
return new ScheduleGroupGrants({
25+
resource: resource,
26+
});
27+
}
28+
29+
protected readonly resource: scheduler.IScheduleGroupRef;
30+
31+
private constructor(props: ScheduleGroupGrantsProps) {
32+
this.resource = props.resource;
33+
}
34+
35+
/**
36+
* Grant list and get schedule permissions for schedules in this group to the given principal
37+
*/
38+
public readSchedules(grantee: iam.IGrantable): iam.Grant {
39+
const actions = ['scheduler:GetSchedule', 'scheduler:ListSchedules'];
40+
return iam.Grant.addToPrincipal({
41+
actions: actions,
42+
grantee: grantee,
43+
resourceArns: [this.arnForScheduleInGroup('*')],
44+
});
45+
}
46+
47+
/**
48+
* Grant create and update schedule permissions for schedules in this group to the given principal
49+
*/
50+
public writeSchedules(grantee: iam.IGrantable): iam.Grant {
51+
const actions = ['scheduler:CreateSchedule', 'scheduler:UpdateSchedule'];
52+
return iam.Grant.addToPrincipal({
53+
actions: actions,
54+
grantee: grantee,
55+
resourceArns: [this.arnForScheduleInGroup('*')],
56+
});
57+
}
58+
59+
/**
60+
* Grant delete schedule permission for schedules in this group to the given principal
61+
*/
62+
public deleteSchedules(grantee: iam.IGrantable): iam.Grant {
63+
const actions = ['scheduler:DeleteSchedule'];
64+
return iam.Grant.addToPrincipal({
65+
actions: actions,
66+
grantee: grantee,
67+
resourceArns: [this.arnForScheduleInGroup('*')],
68+
});
69+
}
70+
71+
private arnForScheduleInGroup(scheduleName: string): string {
72+
return Arn.format({
73+
region: this.resource.env.region,
74+
account: this.resource.env.account,
75+
partition: Aws.PARTITION,
76+
service: 'scheduler',
77+
resource: 'schedule',
78+
resourceName: this.resource.scheduleGroupRef.scheduleGroupName + '/' + scheduleName,
79+
});
80+
}
81+
}

packages/aws-cdk-lib/aws-scheduler/lib/schedule-group.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Construct } from 'constructs';
2-
import { ScheduleGroupGrants } from './scheduler-grants.generated';
2+
import { ScheduleGroupGrants } from './schedule-group-grants';
33
import { CfnScheduleGroup, IScheduleGroupRef, ScheduleGroupReference } from './scheduler.generated';
44
import * as cloudwatch from '../../aws-cloudwatch';
55
import * as iam from '../../aws-iam';
@@ -260,51 +260,25 @@ abstract class ScheduleGroupBase extends Resource implements IScheduleGroup {
260260
});
261261
}
262262

263-
// private arnForScheduleInGroup(scheduleName: string): string {
264-
// return Arn.format({
265-
// region: this.env.region,
266-
// account: this.env.account,
267-
// partition: Aws.PARTITION,
268-
// service: 'scheduler',
269-
// resource: 'schedule',
270-
// resourceName: this.scheduleGroupName + '/' + scheduleName,
271-
// });
272-
// }
273-
274263
/**
275264
* Grant list and get schedule permissions for schedules in this group to the given principal
276265
*/
277266
public grantReadSchedules(identity: iam.IGrantable) {
278267
return this.grants.readSchedules(identity);
279-
// return iam.Grant.addToPrincipal({
280-
// grantee: identity,
281-
// actions: ['scheduler:GetSchedule', 'scheduler:ListSchedules'],
282-
// resourceArns: [this.arnForScheduleInGroup('*')],
283-
// });
284268
}
285269

286270
/**
287271
* Grant create and update schedule permissions for schedules in this group to the given principal
288272
*/
289273
public grantWriteSchedules(identity: iam.IGrantable): iam.Grant {
290274
return this.grants.writeSchedules(identity);
291-
// return iam.Grant.addToPrincipal({
292-
// grantee: identity,
293-
// actions: ['scheduler:CreateSchedule', 'scheduler:UpdateSchedule'],
294-
// resourceArns: [this.arnForScheduleInGroup('*')],
295-
// });
296275
}
297276

298277
/**
299278
* Grant delete schedule permission for schedules in this group to the given principal
300279
*/
301280
public grantDeleteSchedules(identity: iam.IGrantable): iam.Grant {
302281
return this.grants.deleteSchedules(identity);
303-
// return iam.Grant.addToPrincipal({
304-
// grantee: identity,
305-
// actions: ['scheduler:DeleteSchedule'],
306-
// resourceArns: [this.arnForScheduleInGroup('*')],
307-
// });
308282
}
309283
}
310284

packages/aws-cdk-lib/aws-scheduler/test/schedule-group.test.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,11 @@ describe('Schedule Group', () => {
185185
'Fn::Join': [
186186
'',
187187
[
188+
'arn:',
188189
{
189-
'Fn::GetAtt': [
190-
'TestGroupAF88660E',
191-
'Arn',
192-
],
190+
Ref: 'AWS::Partition',
193191
},
194-
'/*',
192+
':scheduler:us-east-1:123456789012:schedule/MyGroup/*',
195193
],
196194
],
197195
},
@@ -228,13 +226,11 @@ describe('Schedule Group', () => {
228226
'Fn::Join': [
229227
'',
230228
[
229+
'arn:',
231230
{
232-
'Fn::GetAtt': [
233-
'TestGroupAF88660E',
234-
'Arn',
235-
],
231+
Ref: 'AWS::Partition',
236232
},
237-
'/*',
233+
':scheduler:us-east-1:123456789012:schedule/MyGroup/*',
238234
],
239235
],
240236
},
@@ -258,8 +254,7 @@ describe('Schedule Group', () => {
258254
group.grantDeleteSchedules(user);
259255

260256
// THEN
261-
let template = Template.fromStack(stack);
262-
template.hasResourceProperties('AWS::IAM::Policy', {
257+
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', {
263258
PolicyDocument: {
264259
Statement: [
265260
{
@@ -269,13 +264,11 @@ describe('Schedule Group', () => {
269264
'Fn::Join': [
270265
'',
271266
[
267+
'arn:',
272268
{
273-
'Fn::GetAtt': [
274-
'TestGroupAF88660E',
275-
'Arn',
276-
],
269+
Ref: 'AWS::Partition',
277270
},
278-
'/*',
271+
':scheduler:us-east-1:123456789012:schedule/MyGroup/*',
279272
],
280273
],
281274
},

version.v2.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "2.229.0",
3-
"alphaVersion": "2.229.0-alpha.0"
2+
"version": "2.229.1",
3+
"alphaVersion": "2.229.1-alpha.0"
44
}

0 commit comments

Comments
 (0)