From d39e8356643ab89fec791df725af4ad8f0bbaecd Mon Sep 17 00:00:00 2001
From: Ian Hou <45278651+iankhou@users.noreply.github.com>
Date: Fri, 10 Jan 2025 12:42:56 -0500
Subject: [PATCH] fix(rds): clusterScailabilityType is spelled wrong and should
be clusterScalabilityType (#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
```
Ran the relevant integration test.
```zsh
# in packages/@aws-cdk-testing/framework-integ
yarn integ test/aws-rds/test/integ.cluster-limitless.js
```
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*
---
packages/aws-cdk-lib/aws-rds/README.md | 2 +-
packages/aws-cdk-lib/aws-rds/lib/cluster.ts | 39 +++++++++++++++++--
.../aws-cdk-lib/aws-rds/test/cluster.test.ts | 36 +++++++++++++++--
3 files changed, 69 insertions(+), 8 deletions(-)
diff --git a/packages/aws-cdk-lib/aws-rds/README.md b/packages/aws-cdk-lib/aws-rds/README.md
index a3862eb036ec4..fd0a8a4ee66e1 100644
--- a/packages/aws-cdk-lib/aws-rds/README.md
+++ b/packages/aws-cdk-lib/aws-rds/README.md
@@ -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,
diff --git a/packages/aws-cdk-lib/aws-rds/lib/cluster.ts b/packages/aws-cdk-lib/aws-rds/lib/cluster.ts
index 48521aedd2a1b..7284a8c42b1e3 100644
--- a/packages/aws-cdk-lib/aws-rds/lib/cluster.ts
+++ b/packages/aws-cdk-lib/aws-rds/lib/cluster.ts
@@ -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;
}
@@ -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.
@@ -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');
}
@@ -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.');
}
@@ -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(),
@@ -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');
}
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 56a426d9cc9ec..9c340a6e41378 100644
--- a/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts
+++ b/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts
@@ -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();
@@ -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');
@@ -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
@@ -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');
@@ -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),