Skip to content

Commit

Permalink
fix: serverlessV2MaxCapacity should not be set to 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed Nov 21, 2024
1 parent 5178050 commit 595510c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 2 additions & 5 deletions packages/aws-cdk-lib/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,8 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
}

private validateServerlessScalingConfig(): void {
if (this.serverlessV2MaxCapacity > 256 || this.serverlessV2MaxCapacity < 0.5) {
throw new Error('serverlessV2MaxCapacity must be >= 0.5 & <= 256');
if (this.serverlessV2MaxCapacity > 256 || this.serverlessV2MaxCapacity < 1) {
throw new Error('serverlessV2MaxCapacity must be >= 1 & <= 256');
}

if (this.serverlessV2MinCapacity > 256 || this.serverlessV2MinCapacity < 0.5) {
Expand All @@ -997,9 +997,6 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
throw new Error('serverlessV2MaxCapacity must be greater than serverlessV2MinCapacity');
}

if (this.serverlessV2MaxCapacity === 0.5 && this.serverlessV2MinCapacity === 0.5) {
throw new Error('If serverlessV2MinCapacity === 0.5 then serverlessV2MaxCapacity must be >=1');
}
const regexp = new RegExp(/^[0-9]+\.?5?$/);
if (!regexp.test(this.serverlessV2MaxCapacity.toString()) || !regexp.test(this.serverlessV2MinCapacity.toString())) {
throw new Error('serverlessV2MinCapacity & serverlessV2MaxCapacity must be in 0.5 step increments, received '+
Expand Down
5 changes: 2 additions & 3 deletions packages/aws-cdk-lib/aws-rds/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ describe('cluster new api', () => {
});

test.each([
[0.5, 300, /serverlessV2MaxCapacity must be >= 0.5 & <= 256/],
[0.5, 0, /serverlessV2MaxCapacity must be >= 0.5 & <= 256/],
[0.5, 300, /serverlessV2MaxCapacity must be >= 1 & <= 256/],
[0.5, 0, /serverlessV2MaxCapacity must be >= 1 & <= 256/],
[0, 1, /serverlessV2MinCapacity must be >= 0.5 & <= 256/],
[300, 1, /serverlessV2MinCapacity must be >= 0.5 & <= 256/],
[0.5, 0.5, /If serverlessV2MinCapacity === 0.5 then serverlessV2MaxCapacity must be >=1/],
[10.1, 12, /serverlessV2MinCapacity & serverlessV2MaxCapacity must be in 0.5 step increments/],
[12, 12.1, /serverlessV2MinCapacity & serverlessV2MaxCapacity must be in 0.5 step increments/],
[5, 1, /serverlessV2MaxCapacity must be greater than serverlessV2MinCapacity/],
Expand Down

0 comments on commit 595510c

Please sign in to comment.