diff --git a/packages/aws-cdk-lib/aws-rds/lib/aurora-cluster-instance.ts b/packages/aws-cdk-lib/aws-rds/lib/aurora-cluster-instance.ts index 359bd3f159c2e..19ad18f4af748 100644 --- a/packages/aws-cdk-lib/aws-rds/lib/aurora-cluster-instance.ts +++ b/packages/aws-cdk-lib/aws-rds/lib/aurora-cluster-instance.ts @@ -518,7 +518,7 @@ class AuroraClusterInstance extends Resource implements IAuroraClusterInstance { // Enhanced CDK Analytics Telemetry addConstructMetadata(this, props); this.tier = props.promotionTier ?? 2; - if (this.tier > 15) { + if (this.tier < 0 || this.tier > 15) { throw new ValidationError(lit`PromotionTier`, 'promotionTier must be between 0-15', this); } diff --git a/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts b/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts index 0188fde277936..63456636121f6 100644 --- a/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts +++ b/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts @@ -140,6 +140,29 @@ describe('cluster new api', () => { }).toThrow(/Provide either vpcSubnets or instanceProps.vpcSubnets, but not both/); }); + test.each([ + -1, 16, + ])('when promotionTier is %s', (promotionTier) => { + // GIVEN + const stack = testStack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + + expect(() => { + // WHEN + new DatabaseCluster(stack, 'Database', { + engine: DatabaseClusterEngine.AURORA_MYSQL, + vpc, + writer: ClusterInstance.provisioned('writer'), + readers: [ + ClusterInstance.provisioned('reader', { + promotionTier, + }), + ], + }); + // THEN + }).toThrow(/promotionTier must be between 0-15/); + }); + test.each([ [0.5, 300, /serverlessV2MaxCapacity must be >= 1 & <= 256/], [0.5, 0, /serverlessV2MaxCapacity must be >= 1 & <= 256/],