Skip to content

Commit a3332b6

Browse files
authored
fix(scheduler): the value of the description property is not reflected to the resource. (#31276)
### Issue # (if applicable) Closes #31269 . ### Reason for this change The `description` property is not used in the `Schedule` class. As a result, the value of the `description` property is not reflected to the resource. ### Description of changes Modify to set the value of props to the `description` property. ### Description of how you validated changes Add a unit test and an integ test. ### 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 6907f1e commit a3332b6

10 files changed

+115
-8
lines changed

packages/@aws-cdk/aws-scheduler-alpha/lib/schedule.ts

+1
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ export class Schedule extends Resource implements ISchedule {
352352
},
353353
startDate: props.start?.toISOString(),
354354
endDate: props.end?.toISOString(),
355+
description: props.description,
355356
});
356357

357358
this.scheduleName = this.getResourceNameAttribute(resource.ref);

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/aws-cdk-scheduler-schedule.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/aws-cdk-scheduler-schedule.template.json

+31
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,37 @@
411411
}
412412
}
413413
}
414+
},
415+
"UseDescription170B07AB": {
416+
"Type": "AWS::Scheduler::Schedule",
417+
"Properties": {
418+
"Description": "test description",
419+
"FlexibleTimeWindow": {
420+
"Mode": "OFF"
421+
},
422+
"ScheduleExpression": "rate(12 hours)",
423+
"ScheduleExpressionTimezone": "Etc/UTC",
424+
"State": "ENABLED",
425+
"Target": {
426+
"Arn": {
427+
"Fn::GetAtt": [
428+
"Function76856677",
429+
"Arn"
430+
]
431+
},
432+
"Input": "\"Input Text\"",
433+
"RetryPolicy": {
434+
"MaximumEventAgeInSeconds": 180,
435+
"MaximumRetryAttempts": 3
436+
},
437+
"RoleArn": {
438+
"Fn::GetAtt": [
439+
"Role1ABCC5F0",
440+
"Arn"
441+
]
442+
}
443+
}
444+
}
414445
}
415446
},
416447
"Parameters": {

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/integtestscheduleDefaultTestDeployAssert24CB3896.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/manifest.json

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.js.snapshot/tree.json

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-scheduler-alpha/test/integ.schedule.ts

+6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ new scheduler.Schedule(stack, 'ScheduleWithTimeFrame', {
104104
end: new Date(`${currentYear + 2}-10-01T00:00:00.000Z`),
105105
});
106106

107+
new scheduler.Schedule(stack, 'UseDescription', {
108+
schedule: expression,
109+
target: target,
110+
description: 'test description',
111+
});
112+
107113
new IntegTest(app, 'integtest-schedule', {
108114
testCases: [stack],
109115
});

packages/@aws-cdk/aws-scheduler-alpha/test/schedule.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,19 @@ describe('Schedule', () => {
214214
});
215215
}).toThrow('The provided duration must be between 1 minute and 1440 minutes, got 0');
216216
});
217+
218+
test('schedule with description', () => {
219+
// WHEN
220+
new Schedule(stack, 'TestSchedule', {
221+
schedule: expr,
222+
target: new SomeLambdaTarget(func, role),
223+
description: 'test description',
224+
});
225+
226+
// THEN
227+
Template.fromStack(stack).hasResourceProperties('AWS::Scheduler::Schedule', {
228+
Description: 'test description',
229+
});
230+
});
217231
});
218232
});

0 commit comments

Comments
 (0)