Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
badmintoncryer committed Nov 16, 2024
1 parent c883725 commit a3a0f47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
9 changes: 3 additions & 6 deletions packages/aws-cdk-lib/aws-ses/lib/configuration-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface ConfigurationSetProps {
*
* This value must be greater than or equal to 5 minutes and less than or equal to 14 hours.
*
* @default - 14 hours
* @default undefined - SES defaults to 14 hours
*/
readonly maxDeliveryDuration?: Duration;
}
Expand Down Expand Up @@ -168,11 +168,8 @@ export class ConfigurationSet extends Resource implements IConfigurationSet {
});

if (props.maxDeliveryDuration && !Token.isUnresolved(props.maxDeliveryDuration)) {
if (props.maxDeliveryDuration.toMilliseconds() < Duration.seconds(1).toMilliseconds()) {
throw new Error(`The maximum delivery duration must be greater than or equal to 5 minutes (300 seconds), got: ${props.maxDeliveryDuration.toMilliseconds()} milliseconds.`);
}
if (props.maxDeliveryDuration.toSeconds() < Duration.minutes(5).toSeconds()) {
throw new Error(`The maximum delivery duration must be greater than or equal to 5 minutes (300 seconds), got: ${props.maxDeliveryDuration.toSeconds()} seconds.`);
if (props.maxDeliveryDuration.toMilliseconds() < Duration.minutes(5).toMilliseconds()) {
throw new Error(`The maximum delivery duration must be greater than or equal to 5 minutes (300_000 milliseconds), got: ${props.maxDeliveryDuration.toSeconds()} milliseconds.`);
}
if (props.maxDeliveryDuration.toSeconds() > Duration.hours(14).toSeconds()) {
throw new Error(`The maximum delivery duration must be less than or equal to 14 hours (50400 seconds), got: ${props.maxDeliveryDuration.toSeconds()} seconds.`);
Expand Down
14 changes: 3 additions & 11 deletions packages/aws-cdk-lib/aws-ses/test/configuration-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,12 @@ test('configuration set with vdmOptions not configured', () => {
});

describe('maxDeliveryDuration', () => {
test('invalid duration less than 1 second', () => {
test.each([Duration.millis(999), Duration.minutes(4)])('invalid duration less than 5 minutes %s', (maxDeliveryDuration) => {
expect(() => {
new ConfigurationSet(stack, 'ConfigurationSet', {
maxDeliveryDuration: Duration.millis(999),
maxDeliveryDuration,
});
}).toThrow('The maximum delivery duration must be greater than or equal to 5 minutes (300 seconds), got: 999 milliseconds.');
});

test('invalid duration less than 5 minutes and greater than 1 second', () => {
expect(() => {
new ConfigurationSet(stack, 'ConfigurationSet', {
maxDeliveryDuration: Duration.minutes(4),
});
}).toThrow('The maximum delivery duration must be greater than or equal to 5 minutes (300 seconds), got: 240 seconds.');
}).toThrow(`The maximum delivery duration must be greater than or equal to 5 minutes (300_000 milliseconds), got: 240000 milliseconds, got: ${maxDeliveryDuration.toMilliseconds()} milliseconds.`);
});

test('invalid duration greater than 14 hours', () => {
Expand Down

0 comments on commit a3a0f47

Please sign in to comment.