Skip to content

Commit 2eebc59

Browse files
authored
fix(scheduler-targets-alpha): incorrect validation of maximumEventAge (#32284)
### Issue # (if applicable) N/A ### Reason for this change The minimum value of `MaximumEventAgeInSeconds` of RetryPolicy is 60 seconds. https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-retrypolicy.html `renderRetryPolicy()` currently throws an error when `maxEventAge` is less than 15 minutes. ### Description of changes Fixed the minimum value of `maxEventAge` to 1 minute. JSDoc is already correct. ### Description of how you validated changes Fixed unit tests for maxEventAge. Fixed a lambda integ test to specify maxEventAge to 1 minute. ### 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 0153da4 commit 2eebc59

23 files changed

+10622
-15281
lines changed

packages/@aws-cdk/aws-scheduler-targets-alpha/lib/target.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ export abstract class ScheduleTargetBase {
154154

155155
private renderRetryPolicy(maximumEventAge: Duration | undefined, maximumRetryAttempts: number | undefined): CfnSchedule.RetryPolicyProperty {
156156
const maxMaxAge = Duration.days(1).toSeconds();
157-
const minMaxAge = Duration.minutes(15).toSeconds();
157+
const minMaxAge = Duration.minutes(1).toSeconds();
158158
let maxAge: number = maxMaxAge;
159159
if (maximumEventAge) {
160160
maxAge = maximumEventAge.toSeconds({ integral: true });
161161
if (maxAge > maxMaxAge) {
162162
throw new Error('Maximum event age is 1 day');
163163
}
164164
if (maxAge < minMaxAge) {
165-
throw new Error('Minimum event age is 15 minutes');
165+
throw new Error('Minimum event age is 1 minute');
166166
}
167167
};
168168
let maxAttempts = 185;

packages/@aws-cdk/aws-scheduler-targets-alpha/test/codebuild-start-build.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -493,16 +493,16 @@ describe('codebuild start build', () => {
493493
})).toThrow(/Maximum event age is 1 day/);
494494
});
495495

496-
test('throws when retry policy max age is less than 15 minutes', () => {
496+
test('throws when retry policy max age is less than 1 minute', () => {
497497
const codebuildProjectTarget = new CodeBuildStartBuild(codebuildProject, {
498-
maxEventAge: Duration.minutes(5),
498+
maxEventAge: Duration.seconds(59),
499499
});
500500

501501
expect(() =>
502502
new Schedule(stack, 'MyScheduleDummy', {
503503
schedule: expr,
504504
target: codebuildProjectTarget,
505-
})).toThrow(/Minimum event age is 15 minutes/);
505+
})).toThrow(/Minimum event age is 1 minute/);
506506
});
507507

508508
test('throws when retry policy max retry attempts is out of the allowed limits', () => {

packages/@aws-cdk/aws-scheduler-targets-alpha/test/codepipeline-start-pipeline-execution.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -501,16 +501,16 @@ describe('codepipeline start execution', () => {
501501
})).toThrow(/Maximum event age is 1 day/);
502502
});
503503

504-
test('throws when retry policy max age is less than 15 minutes', () => {
504+
test('throws when retry policy max age is less than 1 minute', () => {
505505
const codepipelineTarget = new CodePipelineStartPipelineExecution(codepipeline, {
506-
maxEventAge: Duration.minutes(5),
506+
maxEventAge: Duration.seconds(59),
507507
});
508508

509509
expect(() =>
510510
new Schedule(stack, 'MyScheduleDummy', {
511511
schedule: expr,
512512
target: codepipelineTarget,
513-
})).toThrow(/Minimum event age is 15 minutes/);
513+
})).toThrow(/Minimum event age is 1 minute/);
514514
});
515515

516516
test('throws when retry policy max retry attempts is out of the allowed limits', () => {

packages/@aws-cdk/aws-scheduler-targets-alpha/test/event-bridge-put-events.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,16 @@ describe('eventBridge put events', () => {
587587
})).toThrow(/Maximum event age is 1 day/);
588588
});
589589

590-
test('throws when retry policy max age is less than 15 minutes', () => {
590+
test('throws when retry policy max age is less than 1 minute', () => {
591591
const eventBusTarget = new EventBridgePutEvents(eventBusEventEntry, {
592-
maxEventAge: Duration.minutes(5),
592+
maxEventAge: Duration.seconds(59),
593593
});
594594

595595
expect(() =>
596596
new Schedule(stack, 'MyScheduleDummy', {
597597
schedule: expr,
598598
target: eventBusTarget,
599-
})).toThrow(/Minimum event age is 15 minutes/);
599+
})).toThrow(/Minimum event age is 1 minute/);
600600
});
601601

602602
test('throws when retry policy max retry attempts is out of the allowed limits', () => {

packages/@aws-cdk/aws-scheduler-targets-alpha/test/inspector-start-assessment-run.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,16 @@ describe('schedule target', () => {
508508
})).toThrow(/Maximum event age is 1 day/);
509509
});
510510

511-
test('throws when retry policy max age is less than 15 minutes', () => {
511+
test('throws when retry policy max age is less than 1 minute', () => {
512512
const inspectorTarget = new InspectorStartAssessmentRun(template, {
513-
maxEventAge: Duration.minutes(5),
513+
maxEventAge: Duration.seconds(59),
514514
});
515515

516516
expect(() =>
517517
new Schedule(stack, 'MyScheduleDummy', {
518518
schedule: expr,
519519
target: inspectorTarget,
520-
})).toThrow(/Minimum event age is 15 minutes/);
520+
})).toThrow(/Minimum event age is 1 minute/);
521521
});
522522

523523
test('throws when retry policy max retry attempts is out of the allowed limits', () => {

0 commit comments

Comments
 (0)