Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rds): serverlessV2MaxCapacity can be set to 0.5, which is invalid #32232

Merged
merged 6 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1074,8 +1074,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) {
Expand All @@ -1086,9 +1086,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 @@ -116,11 +116,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/],
[-1, 1, /serverlessV2MinCapacity must be >= 0 & <= 256/],
[300, 1, /serverlessV2MinCapacity must be >= 0 & <= 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
Loading