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 a94584bb9dd2e..0a270f98fc888 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 @@ -158,15 +158,15 @@ export class AutoScalingConfiguration extends cdk.Resource implements IAutoScali }); if ( - props.autoScalingConfigurationName !== undefined && + props.autoScalingConfigurationName !== undefined && !cdk.Token.isUnresolved(props.autoScalingConfigurationName) && !/^[A-Za-z0-9][A-Za-z0-9\-_]{3,31}$/.test(props.autoScalingConfigurationName) ) { throw new Error(`autoScalingConfigurationName must match the ^[A-Za-z0-9][A-Za-z0-9\-_]{3,31}$ pattern, got ${props.autoScalingConfigurationName}`); } - const isMinSizeDefined = props.minSize !== undefined && !cdk.Token.isUnresolved(props.minSize) - const isMaxSizeDefined = props.maxSize !== undefined && !cdk.Token.isUnresolved(props.maxSize) + 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}`); } @@ -177,7 +177,7 @@ export class AutoScalingConfiguration extends cdk.Resource implements IAutoScali throw new Error('maxSize must be greater than minSize'); } if ( - props.maxConcurrency !== undefined && + props.maxConcurrency !== undefined && !cdk.Token.isUnresolved(props.maxConcurrency) && (props.maxConcurrency < 1 || props.maxConcurrency > 200) ) { diff --git a/packages/@aws-cdk/aws-apprunner-alpha/test/auto-scaling-configuration.test.ts b/packages/@aws-cdk/aws-apprunner-alpha/test/auto-scaling-configuration.test.ts index eee51ef336a3e..2844d1a6a27cf 100644 --- a/packages/@aws-cdk/aws-apprunner-alpha/test/auto-scaling-configuration.test.ts +++ b/packages/@aws-cdk/aws-apprunner-alpha/test/auto-scaling-configuration.test.ts @@ -77,15 +77,6 @@ test.each([0, 201])('invalid maxConcurrency', (maxConcurrency: number) => { test.each([ ['tes'], ['test-autoscaling-configuration-name-over-limitation'], -])('autoScalingConfigurationName over length limitation (name: %s)', (autoScalingConfigurationName: string) => { - expect(() => { - new AutoScalingConfiguration(stack, 'AutoScalingConfiguration', { - autoScalingConfigurationName, - }); - }).toThrow(`autoScalingConfigurationName must be between 4 and 32 characters long, but it has ${autoScalingConfigurationName.length} characters.`); -}); - -test.each([ ['-test'], ['test-?'], ])('invalid autoScalingConfigurationName (name: %s)', (autoScalingConfigurationName: string) => { @@ -93,5 +84,6 @@ test.each([ new AutoScalingConfiguration(stack, 'AutoScalingConfiguration', { autoScalingConfigurationName, }); - }).toThrow(`autoScalingConfigurationName ${autoScalingConfigurationName} must start with a letter or number, and can contain only letters, numbers, hyphens, and underscores.`); + }).toThrow(`autoScalingConfigurationName must match the ^[A-Za-z0-9][A-Za-z0-9\-_]{3,31}$ pattern, got ${autoScalingConfigurationName}`); }); +