Skip to content

Commit

Permalink
fix(rds): clusterScailabilityType is spelled wrong and should be clus…
Browse files Browse the repository at this point in the history
…terScalabilityType (#32825)

### Issue #32415 

Closes #32415 .

### Reason for this change

Misspelling of the `ClusterScalabilityType` type, enum, and prop.

### Description of changes

Deprecated misspellings of **ClusterScailabilityType**/**clusterScailabilityType** and aliased the misspelling for backwards compatibility. The misspelled name will be removed in the next MV release.

### Describe any new or updated permissions being added

No permissions changes.

### Description of how you validated changes

Added unit tests for the new spelling (ClusterScalabilityType/clusterScalabilityType), and kept unit tests that tested the misspelling.
```zsh
# in packages/aws-cdk-lib
yarn test aws-rds
```
<img width="822" alt="Screenshot 2025-01-09 at 16 10 04" src="https://github.com/user-attachments/assets/9626a0c1-0a5f-45fb-a052-1b1697a5fbdd" />

Ran the relevant integration test.
```zsh
# in packages/@aws-cdk-testing/framework-integ
yarn integ test/aws-rds/test/integ.cluster-limitless.js
```
<img width="916" alt="Screenshot 2025-01-09 at 17 03 44" src="https://github.com/user-attachments/assets/0ed33a38-f6d8-44ee-a210-81e37af5439f" />

Ran Rosetta to verify README changes.
```zsh
./scripts/run-rosetta.sh
```
No complications from README changes in these commits.



### 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*
  • Loading branch information
iankhou authored Jan 10, 2025
1 parent c3ff821 commit d39e835
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-rds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ new rds.DatabaseCluster(this, 'LimitlessDatabaseCluster', {
version: rds.AuroraPostgresEngineVersion.VER_16_4_LIMITLESS,
}),
vpc,
clusterScailabilityType: rds.ClusterScailabilityType.LIMITLESS,
clusterScalabilityType: rds.ClusterScalabilityType.LIMITLESS,
// Requires enabling Performance Insights
enablePerformanceInsights: true,
performanceInsightRetention: rds.PerformanceInsightRetention.MONTHS_1,
Expand Down
39 changes: 36 additions & 3 deletions packages/aws-cdk-lib/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,17 @@ interface DatabaseClusterBaseProps {
*
* Set LIMITLESS if you want to use a limitless database; otherwise, set it to STANDARD.
*
* @default ClusterScalabilityType.STANDARD
*/
readonly clusterScalabilityType?: ClusterScalabilityType;

/**
* [Misspelled] Specifies the scalability mode of the Aurora DB cluster.
*
* Set LIMITLESS if you want to use a limitless database; otherwise, set it to STANDARD.
*
* @default ClusterScailabilityType.STANDARD
* @deprecated Use clusterScalabilityType instead. This will be removed in the next major version.
*/
readonly clusterScailabilityType?: ClusterScailabilityType;
}
Expand Down Expand Up @@ -492,6 +502,25 @@ export enum InstanceUpdateBehaviour {
/**
* The scalability mode of the Aurora DB cluster.
*/
export enum ClusterScalabilityType {
/**
* The cluster uses normal DB instance creation.
*/
STANDARD = 'standard',

/**
* The cluster operates as an Aurora Limitless Database,
* allowing you to create a DB shard group for horizontal scaling (sharding) capabilities.
*
* @see https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/limitless.html
*/
LIMITLESS = 'limitless',
}

/**
* The scalability mode of the Aurora DB cluster.
* @deprecated Use ClusterScalabilityType instead. This will be removed in the next major version.
*/
export enum ClusterScailabilityType {
/**
* The cluster uses normal DB instance creation.
Expand Down Expand Up @@ -701,6 +730,10 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
constructor(scope: Construct, id: string, props: DatabaseClusterBaseProps) {
super(scope, id);

if (props.clusterScalabilityType !== undefined && props.clusterScailabilityType !== undefined) {
throw new Error('You cannot specify both clusterScalabilityType and clusterScailabilityType (deprecated). Use clusterScalabilityType.');
}

if ((props.vpc && props.instanceProps?.vpc) || (!props.vpc && !props.instanceProps?.vpc)) {
throw new Error('Provide either vpc or instanceProps.vpc, but not both');
}
Expand Down Expand Up @@ -802,7 +835,7 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
throw new Error('`enablePerformanceInsights` disabled, but `performanceInsightRetention` or `performanceInsightEncryptionKey` was set');
}

if (props.clusterScailabilityType === ClusterScailabilityType.LIMITLESS) {
if (props.clusterScalabilityType === ClusterScalabilityType.LIMITLESS || props.clusterScailabilityType === ClusterScailabilityType.LIMITLESS) {
if (!props.enablePerformanceInsights) {
throw new Error('Performance Insights must be enabled for Aurora Limitless Database.');
}
Expand Down Expand Up @@ -877,7 +910,7 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase {
}),
storageType: props.storageType?.toString(),
enableLocalWriteForwarding: props.enableLocalWriteForwarding,
clusterScalabilityType: props.clusterScailabilityType,
clusterScalabilityType: props.clusterScalabilityType ?? props.clusterScailabilityType,
// Admin
backtrackWindow: props.backtrackWindow?.toSeconds(),
backupRetentionPeriod: props.backup?.retention?.toDays(),
Expand Down Expand Up @@ -1287,7 +1320,7 @@ export class DatabaseCluster extends DatabaseClusterNew {
setLogRetention(this, props);

// create the instances for only standard aurora clusters
if (props.clusterScailabilityType !== ClusterScailabilityType.LIMITLESS) {
if (props.clusterScalabilityType !== ClusterScalabilityType.LIMITLESS && props.clusterScailabilityType !== ClusterScailabilityType.LIMITLESS) {
if ((props.writer || props.readers) && (props.instances || props.instanceProps)) {
throw new Error('Cannot provide writer or readers if instances or instanceProps are provided');
}
Expand Down
36 changes: 32 additions & 4 deletions packages/aws-cdk-lib/aws-rds/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,34 @@ import {
DatabaseClusterEngine, DatabaseClusterFromSnapshot, ParameterGroup, PerformanceInsightRetention, SubnetGroup, DatabaseSecret,
DatabaseInstanceEngine, SqlServerEngineVersion, SnapshotCredentials, InstanceUpdateBehaviour, NetworkType, ClusterInstance, CaCertificate,
IClusterEngine,
ClusterScalabilityType,
ClusterScailabilityType,
DBClusterStorageType,
} from '../lib';

describe('cluster new api', () => {
describe('errors are thrown', () => {
test('when both clusterScalabilityType and clusterScailabilityType (deprecated) props are provided', () => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

expect(() => {
// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AURORA_MYSQL,
instanceProps: {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
vpc,
},
clusterScalabilityType: ClusterScalabilityType.STANDARD,
clusterScailabilityType: ClusterScailabilityType.STANDARD,
iamAuthentication: true,
});
// THEN
}).toThrow('You cannot specify both clusterScalabilityType and clusterScailabilityType (deprecated). Use clusterScalabilityType.');
});

test('when old and new props are provided', () => {
// GIVEN
const stack = testStack();
Expand Down Expand Up @@ -165,7 +187,10 @@ describe('cluster new api', () => {
});
});

test('cluster scalability option', () => {
test.each([
['clusterScalabilityType', 'clusterScalabilityType', ClusterScalabilityType.STANDARD],
['clusterScailabilityType (deprecated)', 'clusterScailabilityType', ClusterScailabilityType.STANDARD],
])('cluster scalability option with %s', (_, propName, propValue) => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');
Expand All @@ -174,8 +199,8 @@ describe('cluster new api', () => {
new DatabaseCluster(stack, 'Cluster', {
engine: DatabaseClusterEngine.AURORA_MYSQL,
vpc,
clusterScailabilityType: ClusterScailabilityType.STANDARD,
writer: ClusterInstance.serverlessV2('writer'),
[propName]: propValue,
});

// THEN
Expand All @@ -186,7 +211,10 @@ describe('cluster new api', () => {
});

describe('limitless database', () => {
test('with default options', () => {
test.each([
['clusterScalabilityType', 'clusterScalabilityType', ClusterScalabilityType.LIMITLESS],
['clusterScailabilityType (deprecated)', 'clusterScailabilityType', ClusterScailabilityType.LIMITLESS],
])('with default options using %s', (_, propName, propValue) => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');
Expand All @@ -197,7 +225,7 @@ describe('cluster new api', () => {
version: AuroraPostgresEngineVersion.VER_16_4_LIMITLESS,
}),
vpc,
clusterScailabilityType: ClusterScailabilityType.LIMITLESS,
[propName]: propValue,
enablePerformanceInsights: true,
performanceInsightRetention: PerformanceInsightRetention.MONTHS_1,
monitoringInterval: cdk.Duration.minutes(1),
Expand Down

0 comments on commit d39e835

Please sign in to comment.