Skip to content

Commit

Permalink
fix: duration doesn't get accurately compared in alb service base (#2…
Browse files Browse the repository at this point in the history
…1584)

fixes #21560

Duration wasn't getting compared correctly and prevented values above 400 from getting used for `ApplicationLoadBalancedService.idleTimeout`

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
peterwoodworth authored Aug 14, 2022
1 parent fbed1e0 commit 90786d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export interface ApplicationLoadBalancedServiceBaseProps {
readonly enableExecuteCommand?: boolean;

/**
* The load balancer idle timeout, in seconds
* The load balancer idle timeout, in seconds. Can be between 1 and 4000 seconds
*
* @default - CloudFormation sets idle timeout to 60 seconds
*/
Expand Down Expand Up @@ -443,7 +443,8 @@ export abstract class ApplicationLoadBalancedServiceBase extends Construct {
const internetFacing = props.publicLoadBalancer ?? true;

if (props.idleTimeout) {
if (props.idleTimeout > Duration.seconds(4000) || props.idleTimeout < Duration.seconds(1)) {
const idleTimeout = props.idleTimeout.toSeconds();
if (idleTimeout > Duration.seconds(4000).toSeconds() || idleTimeout < Duration.seconds(1).toSeconds()) {
throw new Error('Load balancer idle timeout must be between 1 and 4000 seconds.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs-patterns/test/ec2/l3s.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ test('passes when idleTimeout is between 1 and 4000 seconds', () => {
streamPrefix: 'TestStream',
}),
},
idleTimeout: Duration.seconds(120),
idleTimeout: Duration.seconds(4000),
desiredCount: 2,
});
}).toBeTruthy();
Expand Down

0 comments on commit 90786d6

Please sign in to comment.