diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json index 909fc722fe04a..4ccc8a3069f81 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/aws-ecs-integ-alb-idle-timeout.template.json @@ -906,7 +906,7 @@ }, { "Key": "idle_timeout.timeout_seconds", - "Value": "400" + "Value": "5" } ], "Scheme": "internet-facing", @@ -1101,7 +1101,7 @@ }, { "Key": "idle_timeout.timeout_seconds", - "Value": "400" + "Value": "500" } ], "Scheme": "internet-facing", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json index e969dadbb6f31..4111a3f071c78 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.js.snapshot/tree.json @@ -1516,7 +1516,7 @@ }, { "key": "idle_timeout.timeout_seconds", - "value": "400" + "value": "5" } ], "scheme": "internet-facing", @@ -1855,7 +1855,7 @@ }, { "key": "idle_timeout.timeout_seconds", - "value": "400" + "value": "500" } ], "scheme": "internet-facing", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts index 131e9c4999b38..fe8b376d154a3 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/ec2/integ.multiple-application-load-balanced-ecs-service-idle-timeout.ts @@ -27,7 +27,7 @@ new ApplicationMultipleTargetGroupsEc2Service(stack, 'myService', { loadBalancers: [ { name: 'lb', - idleTimeout: Duration.seconds(400), + idleTimeout: Duration.seconds(5), domainName: 'api.example.com', domainZone: zone, listeners: [ @@ -41,7 +41,7 @@ new ApplicationMultipleTargetGroupsEc2Service(stack, 'myService', { }, { name: 'lb2', - idleTimeout: Duration.seconds(400), + idleTimeout: Duration.seconds(500), domainName: 'frontend.example.com', domainZone: zone, listeners: [ diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts index 7bdeeaa6fcd9a..9ac8750f6ff6c 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts @@ -306,7 +306,7 @@ export interface ApplicationLoadBalancerProps { readonly domainZone?: IHostedZone; /** - * 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 */ @@ -585,7 +585,8 @@ export abstract class ApplicationMultipleTargetGroupsServiceBase extends Constru private validateLbProps(props: ApplicationLoadBalancerProps[]) { for (let prop of props) { if (prop.idleTimeout) { - if (prop.idleTimeout > Duration.seconds(4000) || prop.idleTimeout < Duration.seconds(1)) { + const idleTimeout = prop.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.'); } } diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s.test.ts index 74dd37aea2f5c..0c65e1ae77733 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/l3s.test.ts @@ -983,7 +983,7 @@ test('passes when idleTimeout is between 1 and 4000 seconds for multiAlbService' loadBalancers: [ { name: 'lb', - idleTimeout: Duration.seconds(400), + idleTimeout: Duration.seconds(5), domainName: 'api.example.com', domainZone: new PublicHostedZone(stack, 'HostedZone', { zoneName: 'example.com' }), listeners: [ @@ -997,7 +997,7 @@ test('passes when idleTimeout is between 1 and 4000 seconds for multiAlbService' }, { name: 'lb2', - idleTimeout: Duration.seconds(120), + idleTimeout: Duration.seconds(500), domainName: 'frontend.com', domainZone: new PublicHostedZone(stack, 'HostedZone2', { zoneName: 'frontend.com' }), listeners: [