From 0cac270f7bee1aeaec4a4f9601384ebb14165e36 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Sun, 2 Jun 2024 23:31:56 +0900 Subject: [PATCH] Update packages/@aws-cdk/aws-apprunner-alpha/lib/auto-scaling-configuration.ts Co-authored-by: Luca Pizzini --- .../lib/auto-scaling-configuration.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/aws-apprunner-alpha/lib/auto-scaling-configuration.ts b/packages/@aws-cdk/aws-apprunner-alpha/lib/auto-scaling-configuration.ts index 8ad7d6dec89e8..a94584bb9dd2e 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/lib/auto-scaling-configuration.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/lib/auto-scaling-configuration.ts @@ -165,16 +165,22 @@ export class AutoScalingConfiguration extends cdk.Resource implements IAutoScali throw new Error(`autoScalingConfigurationName must match the ^[A-Za-z0-9][A-Za-z0-9\-_]{3,31}$ pattern, got ${props.autoScalingConfigurationName}`); } - if (props.minSize !== undefined && !cdk.Token.isUnresolved(props.minSize) && (props.minSize < 1 || props.minSize > 25)) { + const isMinSizeDefined = props.minSize !== undefined && !cdk.Token.isUnresolved(props.minSize) + const isMaxSizeDefined = props.maxSize !== undefined && !cdk.Token.isUnresolved(props.maxSize) + if (isMinSizeDefined && (props.minSize < 1 || props.minSize > 25)) { throw new Error(`minSize must be between 1 and 25, got ${props.minSize}`); } - if (props.maxSize !== undefined && (props.maxSize < 1 || props.maxSize > 25)) { + if (isMaxSizeDefined && (props.maxSize < 1 || props.maxSize > 25)) { throw new Error(`maxSize must be between 1 and 25, got ${props.maxSize}`); } - if (props.minSize !== undefined && props.maxSize !== undefined && !(props.minSize < props.maxSize)) { + if (isMinSizeDefined && isMaxSizeDefined && !(props.minSize < props.maxSize)) { throw new Error('maxSize must be greater than minSize'); } - if (props.maxConcurrency !== undefined && (props.maxConcurrency < 1 || props.maxConcurrency > 200)) { + if ( + props.maxConcurrency !== undefined && + !cdk.Token.isUnresolved(props.maxConcurrency) && + (props.maxConcurrency < 1 || props.maxConcurrency > 200) + ) { throw new Error(`maxConcurrency must be between 1 and 200, got ${props.maxConcurrency}`); }