From 7328eb68e2d04ce6fe92ab01e07e93bde30b5936 Mon Sep 17 00:00:00 2001 From: Ian Hou Date: Thu, 9 Jan 2025 15:53:51 -0500 Subject: [PATCH] rds: scalability is spelled wrong --- 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),