From d9090d5b92d80b4c22c4a52965935510a97a7aac Mon Sep 17 00:00:00 2001 From: Luca Pizzini Date: Tue, 25 Jul 2023 09:05:06 +0200 Subject: [PATCH] added token resolution checks --- .../application-load-balanced-fargate-service.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts index 1aaa447c493db..c135666d47fcc 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/application-load-balanced-fargate-service.ts @@ -1,7 +1,7 @@ import { Construct } from 'constructs'; import { ISecurityGroup, SubnetSelection } from '../../../aws-ec2'; import { FargateService, FargateTaskDefinition } from '../../../aws-ecs'; -import { FeatureFlags } from '../../../core'; +import { FeatureFlags, Token } from '../../../core'; import * as cxapi from '../../../cx-api'; import { ApplicationLoadBalancedServiceBase, ApplicationLoadBalancedServiceBaseProps } from '../base/application-load-balanced-service-base'; import { FargateServiceBaseProps } from '../base/fargate-service-base'; @@ -99,7 +99,13 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc this.validateHealthyPercentage('minHealthyPercent', props.minHealthyPercent); this.validateHealthyPercentage('maxHealthyPercent', props.maxHealthyPercent); - if (props.minHealthyPercent && props.maxHealthyPercent && props.minHealthyPercent >= props.maxHealthyPercent) { + if ( + props.minHealthyPercent && + !Token.isUnresolved(props.minHealthyPercent) && + props.maxHealthyPercent && + !Token.isUnresolved(props.maxHealthyPercent) && + props.minHealthyPercent >= props.maxHealthyPercent + ) { throw new Error('Minimum healthy percent must be less than maximum healthy percent.'); } @@ -132,7 +138,7 @@ export class ApplicationLoadBalancedFargateService extends ApplicationLoadBalanc * Throws an error if the specified percent is not an integer or negative. */ private validateHealthyPercentage(name: string, value?: number) { - if (value === undefined) { return; } + if (value === undefined || Token.isUnresolved(value)) { return; } if (!Number.isInteger(value) || value < 0) { throw new Error(`${name}: Must be a non-negative integer; received ${value}`); }