Skip to content

Commit 3fe229d

Browse files
authored
fix(rds): serverlessV2MaxCapacity can be set to 0.5, which is invalid (#32232)
### Issue # (if applicable) N/A ### Reason for this change In [CFn docs](https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-rds-dbcluster-serverlessv2scalingconfiguration.html#cfn-rds-dbcluster-serverlessv2scalingconfiguration-maxcapacity), MaximumCapacity value must be higher than 0.5 ACUs. ``` The maximum capacity must be higher than 0.5 ACUs. ``` This means MaximumCapacity cannot be set to 0.5 ACUs. However, in the CDK, `serverlessV2MaxCapacity` can be set to 0.5, which is invalid. When I attempted to deploy with `serverlessV2MaxCapacity` set to 0.5, I encountered the following error: > CREATE_FAILED | AWS::RDS::DBCluster | Integ-Cluster (IntegCluster4261F36F) Resource handler returned message: "Serverless v2 maximum capacity 0.5 isn't valid. The maximum capacity must be at least 1.0. In the Management Console, Maximum Capacity cannot be set to 0.5. <img width="854" alt="image" src="https://github.com/user-attachments/assets/37c127d8-cd5d-4e88-a699-dff7929a8b95"> ### Description of changes Fix a validation. ### Description of how you validated changes Fix unit tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent ce3598b commit 3fe229d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

packages/aws-cdk-lib/aws-rds/lib/cluster.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,8 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
10741074
}
10751075

10761076
private validateServerlessScalingConfig(): void {
1077-
if (this.serverlessV2MaxCapacity > 256 || this.serverlessV2MaxCapacity < 0.5) {
1078-
throw new Error('serverlessV2MaxCapacity must be >= 0.5 & <= 256');
1077+
if (this.serverlessV2MaxCapacity > 256 || this.serverlessV2MaxCapacity < 1) {
1078+
throw new Error('serverlessV2MaxCapacity must be >= 1 & <= 256');
10791079
}
10801080

10811081
if (this.serverlessV2MinCapacity > 256 || this.serverlessV2MinCapacity < 0) {
@@ -1086,9 +1086,6 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
10861086
throw new Error('serverlessV2MaxCapacity must be greater than serverlessV2MinCapacity');
10871087
}
10881088

1089-
if (this.serverlessV2MaxCapacity === 0.5 && this.serverlessV2MinCapacity === 0.5) {
1090-
throw new Error('If serverlessV2MinCapacity === 0.5 then serverlessV2MaxCapacity must be >=1');
1091-
}
10921089
const regexp = new RegExp(/^[0-9]+\.?5?$/);
10931090
if (!regexp.test(this.serverlessV2MaxCapacity.toString()) || !regexp.test(this.serverlessV2MinCapacity.toString())) {
10941091
throw new Error('serverlessV2MinCapacity & serverlessV2MaxCapacity must be in 0.5 step increments, received '+

packages/aws-cdk-lib/aws-rds/test/cluster.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ describe('cluster new api', () => {
116116
});
117117

118118
test.each([
119-
[0.5, 300, /serverlessV2MaxCapacity must be >= 0.5 & <= 256/],
120-
[0.5, 0, /serverlessV2MaxCapacity must be >= 0.5 & <= 256/],
119+
[0.5, 300, /serverlessV2MaxCapacity must be >= 1 & <= 256/],
120+
[0.5, 0, /serverlessV2MaxCapacity must be >= 1 & <= 256/],
121121
[-1, 1, /serverlessV2MinCapacity must be >= 0 & <= 256/],
122122
[300, 1, /serverlessV2MinCapacity must be >= 0 & <= 256/],
123-
[0.5, 0.5, /If serverlessV2MinCapacity === 0.5 then serverlessV2MaxCapacity must be >=1/],
124123
[10.1, 12, /serverlessV2MinCapacity & serverlessV2MaxCapacity must be in 0.5 step increments/],
125124
[12, 12.1, /serverlessV2MinCapacity & serverlessV2MaxCapacity must be in 0.5 step increments/],
126125
[5, 1, /serverlessV2MaxCapacity must be greater than serverlessV2MinCapacity/],

0 commit comments

Comments
 (0)