diff --git a/packages/@aws-cdk/aws-rds/README.md b/packages/@aws-cdk/aws-rds/README.md index be60c3f0a1a70..ad0b04ea9b589 100644 --- a/packages/@aws-cdk/aws-rds/README.md +++ b/packages/@aws-cdk/aws-rds/README.md @@ -48,14 +48,14 @@ use the static factory methods on `DatabaseClusterEngine`: ```typescript new rds.DatabaseCluster(this, 'Database', { engine: rds.DatabaseClusterEngine.aurora({ - version: '5.6.mysql_aurora.1.17.9', + version: rds.AuroraEngineVersion.VER_1_17_9, // different version class for each engine type }, ... }) ``` -See [the AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-engineversion) -for a list of the supported versions for each engine type. +If there isn't a constant for the exact version you want to use, +all of the `Version` classes have a static `of` method that can be used to create an arbitrary version. By default, the master password will be generated and stored in AWS Secrets Manager with auto-generated description. @@ -86,13 +86,16 @@ use the static factory methods on `DatabaseInstanceEngine`: ```typescript const instance = new rds.DatabaseInstance(this, 'Instance', { - engine: rds.DatabaseInstanceEngine.oracleSe1({ - version: '19.0.0.0', + engine: rds.DatabaseInstanceEngine.oracleSe2({ + version: rds.OracleEngineVersion.VER_19, // different version class for each engine type }), ... }); ``` +If there isn't a constant for the exact version you want to use, +all of the `Version` classes have a static `of` method that can be used to create an arbitrary version. + To use the storage auto scaling option of RDS you can specify the maximum allocated storage. This is the upper limit to which RDS can automatically scale the storage. More info can be found [here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PIOPS.StorageTypes.html#USER_PIOPS.Autoscaling) @@ -173,24 +176,27 @@ instance.addRotationSingleUser(); // Will rotate automatically after 30 days [example of setting up master password rotation for a cluster](test/integ.cluster-rotation.lit.ts) The multi user rotation scheme is also available: + ```ts instance.addRotationMultiUser('MyUser', { - secret: myImportedSecret // This secret must have the `masterarn` key + secret: myImportedSecret, // This secret must have the `masterarn` key }); ``` It's also possible to create user credentials together with the instance/cluster and add rotation: + ```ts const myUserSecret = new rds.DatabaseSecret(this, 'MyUserSecret', { - username: 'myuser' - masterSecret: instance.secret + username: 'myuser', + masterSecret: instance.secret, }); const myUserSecretAttached = myUserSecret.attach(instance); // Adds DB connections information in the secret instance.addRotationMultiUser('MyUser', { // Add rotation using the multi user scheme - secret: myUserSecretAttached + secret: myUserSecretAttached, }); ``` + **Note**: This user must be created manually in the database using the master credentials. The rotation will start as soon as this user exists. diff --git a/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts b/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts index 799cd14d88694..b16a9799d59c0 100644 --- a/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts +++ b/packages/@aws-cdk/aws-rds/lib/cluster-engine.ts @@ -2,8 +2,8 @@ import * as iam from '@aws-cdk/aws-iam'; import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; import * as core from '@aws-cdk/core'; import { IEngine } from './engine'; +import { EngineVersion } from './engine-version'; import { IParameterGroup, ParameterGroup } from './parameter-group'; -import { calculateParameterGroupFamily, ParameterGroupFamilyMapping } from './private/parameter-group-family-mapping'; /** * The extra options passed to the {@link IClusterEngine.bindToCluster} method. @@ -71,15 +71,14 @@ interface ClusterEngineBaseProps { readonly engineType: string; readonly singleUserRotationApplication: secretsmanager.SecretRotationApplication; readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication; - readonly parameterGroupFamilies?: ParameterGroupFamilyMapping[]; readonly defaultPort?: number; - readonly engineVersion?: string; + readonly engineVersion?: EngineVersion; } abstract class ClusterEngineBase implements IClusterEngine { public readonly engineType: string; - public readonly engineVersion?: string; - public readonly parameterGroupFamily: string; + public readonly engineVersion?: EngineVersion; + public readonly parameterGroupFamily?: string; public readonly singleUserRotationApplication: secretsmanager.SecretRotationApplication; public readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication; @@ -91,11 +90,7 @@ abstract class ClusterEngineBase implements IClusterEngine { this.multiUserRotationApplication = props.multiUserRotationApplication; this.defaultPort = props.defaultPort; this.engineVersion = props.engineVersion; - const parameterGroupFamily = calculateParameterGroupFamily(props.parameterGroupFamilies, props.engineVersion); - if (parameterGroupFamily === undefined) { - throw new Error(`No parameter group family found for database engine ${this.engineType} with version ${this.engineVersion}.`); - } - this.parameterGroupFamily = parameterGroupFamily; + this.parameterGroupFamily = this.engineVersion ? `${this.engineType}${this.engineVersion.majorVersion}` : undefined; } public bindToCluster(scope: core.Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { @@ -114,7 +109,22 @@ abstract class ClusterEngineBase implements IClusterEngine { protected abstract defaultParameterGroup(scope: core.Construct): IParameterGroup | undefined; } +interface MysqlClusterEngineBaseProps { + readonly engineType: string; + readonly engineVersion?: EngineVersion; + readonly defaultMajorVersion: string; +} + abstract class MySqlClusterEngineBase extends ClusterEngineBase { + constructor(props: MysqlClusterEngineBaseProps) { + super({ + ...props, + singleUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_SINGLE_USER, + multiUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_MULTI_USER, + engineVersion: props.engineVersion ? props.engineVersion : { majorVersion: props.defaultMajorVersion }, + }); + } + public bindToCluster(scope: core.Construct, options: ClusterEngineBindOptions): ClusterEngineConfig { const config = super.bindToCluster(scope, options); const parameterGroup = options.parameterGroup ?? (options.s3ImportRole || options.s3ExportRole @@ -137,35 +147,86 @@ abstract class MySqlClusterEngineBase extends ClusterEngineBase { } /** - * Common properties of all cluster engines. + * The versions for the Aurora cluster engine + * (those returned by {@link DatabaseClusterEngine.aurora}). */ -interface ClusterEngineProps { +export class AuroraEngineVersion { + /** Version "5.6.10a". */ + public static readonly VER_10A = AuroraEngineVersion.builtIn_5_6('10a', false); + /** Version "5.6.mysql_aurora.1.17.9". */ + public static readonly VER_1_17_9 = AuroraEngineVersion.builtIn_5_6('1.17.9'); + /** Version "5.6.mysql_aurora.1.19.0". */ + public static readonly VER_1_19_0 = AuroraEngineVersion.builtIn_5_6('1.19.0'); + /** Version "5.6.mysql_aurora.1.19.1". */ + public static readonly VER_1_19_1 = AuroraEngineVersion.builtIn_5_6('1.19.1'); + /** Version "5.6.mysql_aurora.1.19.2". */ + public static readonly VER_1_19_2 = AuroraEngineVersion.builtIn_5_6('1.19.2'); + /** Version "5.6.mysql_aurora.1.19.5". */ + public static readonly VER_1_19_5 = AuroraEngineVersion.builtIn_5_6('1.19.5'); + /** Version "5.6.mysql_aurora.1.19.6". */ + public static readonly VER_1_19_6 = AuroraEngineVersion.builtIn_5_6('1.19.6'); + /** Version "5.6.mysql_aurora.1.20.0". */ + public static readonly VER_1_20_0 = AuroraEngineVersion.builtIn_5_6('1.20.0'); + /** Version "5.6.mysql_aurora.1.20.1". */ + public static readonly VER_1_20_1 = AuroraEngineVersion.builtIn_5_6('1.20.1'); + /** Version "5.6.mysql_aurora.1.21.0". */ + public static readonly VER_1_21_0 = AuroraEngineVersion.builtIn_5_6('1.21.0'); + /** Version "5.6.mysql_aurora.1.22.0". */ + public static readonly VER_1_22_0 = AuroraEngineVersion.builtIn_5_6('1.22.0'); + /** Version "5.6.mysql_aurora.1.22.1". */ + public static readonly VER_1_22_1 = AuroraEngineVersion.builtIn_5_6('1.22.1'); + /** Version "5.6.mysql_aurora.1.22.1.3". */ + public static readonly VER_1_22_1_3 = AuroraEngineVersion.builtIn_5_6('1.22.1.3'); + /** Version "5.6.mysql_aurora.1.22.2". */ + public static readonly VER_1_22_2 = AuroraEngineVersion.builtIn_5_6('1.22.2'); + /** - * The exact version of the engine. + * Create a new AuroraEngineVersion with an arbitrary version. * - * @example "5.6.mysql_aurora.1.22.2" - * @default - no version specified + * @param auroraFullVersion the full version string, + * for example "5.6.mysql_aurora.1.78.3.6" + * @param auroraMajorVersion the major version of the engine, + * defaults to "5.6" */ - readonly version?: string; + public static of(auroraFullVersion: string, auroraMajorVersion?: string): AuroraEngineVersion { + return new AuroraEngineVersion(auroraFullVersion, auroraMajorVersion); + } + + private static builtIn_5_6(minorVersion: string, addStandardPrefix: boolean = true): AuroraEngineVersion { + return new AuroraEngineVersion(`5.6.${addStandardPrefix ? 'mysql_aurora.' : ''}${minorVersion}`); + } + + /** The full version string, for example, "5.6.mysql_aurora.1.78.3.6". */ + public readonly auroraFullVersion: string; + /** The major version of the engine. Currently, it's always "5.6". */ + public readonly auroraMajorVersion: string; + + private constructor(auroraFullVersion: string, auroraMajorVersion: string = '5.6') { + this.auroraFullVersion = auroraFullVersion; + this.auroraMajorVersion = auroraMajorVersion; + } } /** * Creation properties of the plain Aurora database cluster engine. * Used in {@link DatabaseClusterEngine.aurora}. */ -export interface AuroraClusterEngineProps extends ClusterEngineProps { +export interface AuroraClusterEngineProps { + /** The version of the Aurora cluster engine. */ + readonly version: AuroraEngineVersion; } class AuroraClusterEngine extends MySqlClusterEngineBase { - constructor(props: AuroraClusterEngineProps = {}) { + constructor(version?: AuroraEngineVersion) { super({ engineType: 'aurora', - singleUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_SINGLE_USER, - multiUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_MULTI_USER, - parameterGroupFamilies: [ - { engineMajorVersion: '5.6', parameterGroupFamily: 'aurora5.6' }, - ], - engineVersion: props.version, + engineVersion: version + ? { + fullVersion: version.auroraFullVersion, + majorVersion: version.auroraMajorVersion, + } + : undefined, + defaultMajorVersion: '5.6', }); } @@ -176,23 +237,99 @@ class AuroraClusterEngine extends MySqlClusterEngineBase { } } +/** + * The versions for the Aurora MySQL cluster engine + * (those returned by {@link DatabaseClusterEngine.auroraMysql}). + */ +export class AuroraMysqlEngineVersion { + /** Version "5.7.12". */ + public static readonly VER_5_7_12 = AuroraMysqlEngineVersion.builtIn_5_7('12', false); + /** Version "5.7.mysql_aurora.2.03.2". */ + public static readonly VER_2_03_2 = AuroraMysqlEngineVersion.builtIn_5_7('2.03.2'); + /** Version "5.7.mysql_aurora.2.03.3". */ + public static readonly VER_2_03_3 = AuroraMysqlEngineVersion.builtIn_5_7('2.03.3'); + /** Version "5.7.mysql_aurora.2.03.4". */ + public static readonly VER_2_03_4 = AuroraMysqlEngineVersion.builtIn_5_7('2.03.4'); + /** Version "5.7.mysql_aurora.2.04.0". */ + public static readonly VER_2_04_0 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.0'); + /** Version "5.7.mysql_aurora.2.04.1". */ + public static readonly VER_2_04_1 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.1'); + /** Version "5.7.mysql_aurora.2.04.2". */ + public static readonly VER_2_04_2 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.2'); + /** Version "5.7.mysql_aurora.2.04.3". */ + public static readonly VER_2_04_3 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.3'); + /** Version "5.7.mysql_aurora.2.04.4". */ + public static readonly VER_2_04_4 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.4'); + /** Version "5.7.mysql_aurora.2.04.5". */ + public static readonly VER_2_04_5 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.5'); + /** Version "5.7.mysql_aurora.2.04.6". */ + public static readonly VER_2_04_6 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.6'); + /** Version "5.7.mysql_aurora.2.04.7". */ + public static readonly VER_2_04_7 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.7'); + /** Version "5.7.mysql_aurora.2.04.8". */ + public static readonly VER_2_04_8 = AuroraMysqlEngineVersion.builtIn_5_7('2.04.8'); + /** Version "5.7.mysql_aurora.2.05.0". */ + public static readonly VER_2_05_0 = AuroraMysqlEngineVersion.builtIn_5_7('2.05.0'); + /** Version "5.7.mysql_aurora.2.06.0". */ + public static readonly VER_2_06_0 = AuroraMysqlEngineVersion.builtIn_5_7('2.06.0'); + /** Version "5.7.mysql_aurora.2.07.0". */ + public static readonly VER_2_07_0 = AuroraMysqlEngineVersion.builtIn_5_7('2.07.0'); + /** Version "5.7.mysql_aurora.2.07.1". */ + public static readonly VER_2_07_1 = AuroraMysqlEngineVersion.builtIn_5_7('2.07.1'); + /** Version "5.7.mysql_aurora.2.07.2". */ + public static readonly VER_2_07_2 = AuroraMysqlEngineVersion.builtIn_5_7('2.07.2'); + /** Version "5.7.mysql_aurora.2.08.0". */ + public static readonly VER_2_08_0 = AuroraMysqlEngineVersion.builtIn_5_7('2.08.0'); + /** Version "5.7.mysql_aurora.2.08.1". */ + public static readonly VER_2_08_1 = AuroraMysqlEngineVersion.builtIn_5_7('2.08.1'); + + /** + * Create a new AuroraMysqlEngineVersion with an arbitrary version. + * + * @param auroraMysqlFullVersion the full version string, + * for example "5.7.mysql_aurora.2.78.3.6" + * @param auroraMysqlMajorVersion the major version of the engine, + * defaults to "5.7" + */ + public static of(auroraMysqlFullVersion: string, auroraMysqlMajorVersion?: string): AuroraMysqlEngineVersion { + return new AuroraMysqlEngineVersion(auroraMysqlFullVersion, auroraMysqlMajorVersion); + } + + private static builtIn_5_7(minorVersion: string, addStandardPrefix: boolean = true): AuroraMysqlEngineVersion { + return new AuroraMysqlEngineVersion(`5.7.${addStandardPrefix ? 'mysql_aurora.' : ''}${minorVersion}`); + } + + /** The full version string, for example, "5.7.mysql_aurora.1.78.3.6". */ + public readonly auroraMysqlFullVersion: string; + /** The major version of the engine. Currently, it's always "5.7". */ + public readonly auroraMysqlMajorVersion: string; + + private constructor(auroraMysqlFullVersion: string, auroraMysqlMajorVersion: string = '5.7') { + this.auroraMysqlFullVersion = auroraMysqlFullVersion; + this.auroraMysqlMajorVersion = auroraMysqlMajorVersion; + } +} + /** * Creation properties of the Aurora MySQL database cluster engine. * Used in {@link DatabaseClusterEngine.auroraMysql}. */ -export interface AuroraMysqlClusterEngineProps extends ClusterEngineProps { +export interface AuroraMysqlClusterEngineProps { + /** The version of the Aurora MySQL cluster engine. */ + readonly version: AuroraMysqlEngineVersion; } class AuroraMysqlClusterEngine extends MySqlClusterEngineBase { - constructor(props: AuroraMysqlClusterEngineProps = {}) { + constructor(version?: AuroraMysqlEngineVersion) { super({ engineType: 'aurora-mysql', - singleUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_SINGLE_USER, - multiUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_MULTI_USER, - parameterGroupFamilies: [ - { engineMajorVersion: '5.7', parameterGroupFamily: 'aurora-mysql5.7' }, - ], - engineVersion: props.version, + engineVersion: version + ? { + fullVersion: version.auroraMysqlFullVersion, + majorVersion: version.auroraMysqlMajorVersion, + } + : undefined, + defaultMajorVersion: '5.7', }); } @@ -202,30 +339,95 @@ class AuroraMysqlClusterEngine extends MySqlClusterEngineBase { } } +/** + * The versions for the Aurora PostgreSQL cluster engine + * (those returned by {@link DatabaseClusterEngine.auroraPostgres}). + */ +export class AuroraPostgresEngineVersion { + /** Version "9.6.8". */ + public static readonly VER_9_6_8 = AuroraPostgresEngineVersion.of('9.6.8', '9.6'); + /** Version "9.6.9". */ + public static readonly VER_9_6_9 = AuroraPostgresEngineVersion.of('9.6.9', '9.6'); + /** Version "9.6.11". */ + public static readonly VER_9_6_11 = AuroraPostgresEngineVersion.of('9.6.11', '9.6'); + /** Version "9.6.12". */ + public static readonly VER_9_6_12 = AuroraPostgresEngineVersion.of('9.6.12', '9.6'); + /** Version "9.6.16". */ + public static readonly VER_9_6_16 = AuroraPostgresEngineVersion.of('9.6.16', '9.6'); + /** Version "9.6.17". */ + public static readonly VER_9_6_17 = AuroraPostgresEngineVersion.of('9.6.17', '9.6'); + /** Version "10.4". */ + public static readonly VER_10_4 = AuroraPostgresEngineVersion.of('10.4', '10'); + /** Version "10.5". */ + public static readonly VER_10_5 = AuroraPostgresEngineVersion.of('10.5', '10'); + /** Version "10.6". */ + public static readonly VER_10_6 = AuroraPostgresEngineVersion.of('10.6', '10'); + /** Version "10.7". */ + public static readonly VER_10_7 = AuroraPostgresEngineVersion.of('10.7', '10'); + /** Version "10.11". */ + public static readonly VER_10_11 = AuroraPostgresEngineVersion.of('10.11', '10'); + /** Version "10.12". */ + public static readonly VER_10_12 = AuroraPostgresEngineVersion.of('10.12', '10'); + /** Version "11.4". */ + public static readonly VER_11_4 = AuroraPostgresEngineVersion.of('11.4', '11'); + /** Version "11.6". */ + public static readonly VER_11_6 = AuroraPostgresEngineVersion.of('11.6', '11'); + /** Version "11.7". */ + public static readonly VER_11_7 = AuroraPostgresEngineVersion.of('11.7', '11'); + + /** + * Create a new AuroraPostgresEngineVersion with an arbitrary version. + * + * @param auroraPostgresFullVersion the full version string, + * for example "9.6.25.1" + * @param auroraPostgresMajorVersion the major version of the engine, + * for example "9.6" + */ + public static of(auroraPostgresFullVersion: string, auroraPostgresMajorVersion: string): AuroraPostgresEngineVersion { + return new AuroraPostgresEngineVersion(auroraPostgresFullVersion, auroraPostgresMajorVersion); + } + + /** The full version string, for example, "9.6.25.1". */ + public readonly auroraPostgresFullVersion: string; + /** The major version of the engine, for example, "9.6". */ + public readonly auroraPostgresMajorVersion: string; + + private constructor(auroraPostgresFullVersion: string, auroraPostgresMajorVersion: string) { + this.auroraPostgresFullVersion = auroraPostgresFullVersion; + this.auroraPostgresMajorVersion = auroraPostgresMajorVersion; + } +} + /** * Creation properties of the Aurora PostgreSQL database cluster engine. * Used in {@link DatabaseClusterEngine.auroraPostgres}. */ -export interface AuroraPostgresClusterEngineProps extends ClusterEngineProps { +export interface AuroraPostgresClusterEngineProps { + /** The version of the Aurora PostgreSQL cluster engine. */ + readonly version: AuroraPostgresEngineVersion; } class AuroraPostgresClusterEngine extends ClusterEngineBase { - constructor(props: AuroraPostgresClusterEngineProps = {}) { + constructor(version?: AuroraPostgresEngineVersion) { super({ engineType: 'aurora-postgresql', singleUserRotationApplication: secretsmanager.SecretRotationApplication.POSTGRES_ROTATION_SINGLE_USER, multiUserRotationApplication: secretsmanager.SecretRotationApplication.POSTGRES_ROTATION_MULTI_USER, - parameterGroupFamilies: [ - { engineMajorVersion: '9.6', parameterGroupFamily: 'aurora-postgresql9.6' }, - { engineMajorVersion: '10', parameterGroupFamily: 'aurora-postgresql10' }, - { engineMajorVersion: '11', parameterGroupFamily: 'aurora-postgresql11' }, - ], defaultPort: 5432, - engineVersion: props.version, + engineVersion: version + ? { + fullVersion: version.auroraPostgresFullVersion, + majorVersion: version.auroraPostgresMajorVersion, + } + : undefined, }); } protected defaultParameterGroup(scope: core.Construct): IParameterGroup | undefined { + if (!this.parameterGroupFamily) { + throw new Error('Could not create a new ParameterGroup for an unversioned aurora-postgresql cluster engine. ' + + 'Please either use a versioned engine, or pass an explicit ParameterGroup when creating the cluster'); + } return ParameterGroup.fromParameterGroupName(scope, 'AuroraPostgreSqlDatabaseClusterEngineDefaultParameterGroup', `default.${this.parameterGroupFamily}`); } @@ -236,24 +438,42 @@ class AuroraPostgresClusterEngine extends ClusterEngineBase { * used for secret rotation. */ export class DatabaseClusterEngine { + /** + * The unversioned 'aurora' cluster engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link aurora()} method + */ public static readonly AURORA: IClusterEngine = new AuroraClusterEngine(); + /** + * The unversioned 'aurora-msql' cluster engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link auroraMysql()} method + */ public static readonly AURORA_MYSQL: IClusterEngine = new AuroraMysqlClusterEngine(); + /** + * The unversioned 'aurora-postgresql' cluster engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link auroraPostgres()} method + */ public static readonly AURORA_POSTGRESQL: IClusterEngine = new AuroraPostgresClusterEngine(); /** Creates a new plain Aurora database cluster engine. */ public static aurora(props: AuroraClusterEngineProps): IClusterEngine { - return new AuroraClusterEngine(props); + return new AuroraClusterEngine(props.version); } /** Creates a new Aurora MySQL database cluster engine. */ public static auroraMysql(props: AuroraMysqlClusterEngineProps): IClusterEngine { - return new AuroraMysqlClusterEngine(props); + return new AuroraMysqlClusterEngine(props.version); } /** Creates a new Aurora PostgreSQL database cluster engine. */ public static auroraPostgres(props: AuroraPostgresClusterEngineProps): IClusterEngine { - return new AuroraPostgresClusterEngine(props); + return new AuroraPostgresClusterEngine(props.version); } } diff --git a/packages/@aws-cdk/aws-rds/lib/cluster.ts b/packages/@aws-cdk/aws-rds/lib/cluster.ts index b44d7ecc19050..2318fb1d9762e 100644 --- a/packages/@aws-cdk/aws-rds/lib/cluster.ts +++ b/packages/@aws-cdk/aws-rds/lib/cluster.ts @@ -420,7 +420,7 @@ export class DatabaseCluster extends DatabaseClusterBase { const cluster = new CfnDBCluster(this, 'Resource', { // Basic engine: props.engine.engineType, - engineVersion: props.engine.engineVersion, + engineVersion: props.engine.engineVersion?.fullVersion, dbClusterIdentifier: props.clusterIdentifier, dbSubnetGroupName: subnetGroup.ref, vpcSecurityGroupIds: securityGroups.map(sg => sg.securityGroupId), @@ -497,7 +497,7 @@ export class DatabaseCluster extends DatabaseClusterBase { const instance = new CfnDBInstance(this, `Instance${instanceIndex}`, { // Link to cluster engine: props.engine.engineType, - engineVersion: props.engine.engineVersion, + engineVersion: props.engine.engineVersion?.fullVersion, dbClusterIdentifier: cluster.ref, dbInstanceIdentifier: instanceIdentifier, // Instance properties diff --git a/packages/@aws-cdk/aws-rds/lib/engine-version.ts b/packages/@aws-cdk/aws-rds/lib/engine-version.ts new file mode 100644 index 0000000000000..167f9094b591f --- /dev/null +++ b/packages/@aws-cdk/aws-rds/lib/engine-version.ts @@ -0,0 +1,23 @@ +/** + * A version of an engine - + * for either a cluster, or instance. + */ +export interface EngineVersion { + /** + * The full version string of the engine, + * for example, "5.6.mysql_aurora.1.22.1". + * It can be undefined, + * which means RDS should use whatever version it deems appropriate for the given engine type. + * + * @default - no version specified + */ + readonly fullVersion?: string; + + /** + * The major version of the engine, + * for example, "5.6". + * Used in specifying the ParameterGroup family + * and OptionGroup version for this engine. + */ + readonly majorVersion: string; +} diff --git a/packages/@aws-cdk/aws-rds/lib/engine.ts b/packages/@aws-cdk/aws-rds/lib/engine.ts index 4d6a179be8740..b1ccef4084c87 100644 --- a/packages/@aws-cdk/aws-rds/lib/engine.ts +++ b/packages/@aws-cdk/aws-rds/lib/engine.ts @@ -1,3 +1,5 @@ +import { EngineVersion } from './engine-version'; + /** * A common interface for database engines. * Don't implement this interface directly, @@ -14,13 +16,16 @@ export interface IEngine { * * @default - use the default version for this engine type */ - readonly engineVersion?: string; + readonly engineVersion?: EngineVersion; /** * The family to use for ParameterGroups using this engine. * This is usually equal to "", * but can sometimes be a variation of that. * You can pass this property when creating new ParameterGroup. + * + * @default - the ParameterGroup family is not known + * (which means the major version of the engine is also not known) */ - readonly parameterGroupFamily: string; + readonly parameterGroupFamily?: string; } diff --git a/packages/@aws-cdk/aws-rds/lib/index.ts b/packages/@aws-cdk/aws-rds/lib/index.ts index b2da8e110654c..d03d0ce49bb39 100644 --- a/packages/@aws-cdk/aws-rds/lib/index.ts +++ b/packages/@aws-cdk/aws-rds/lib/index.ts @@ -1,4 +1,5 @@ export * from './engine'; +export * from './engine-version'; export * from './cluster'; export * from './cluster-ref'; export * from './cluster-engine'; diff --git a/packages/@aws-cdk/aws-rds/lib/instance-engine.ts b/packages/@aws-cdk/aws-rds/lib/instance-engine.ts index ecaf86d1c9055..b2099933e24be 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance-engine.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance-engine.ts @@ -1,8 +1,7 @@ -import * as ec2 from '@aws-cdk/aws-ec2'; import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; import * as core from '@aws-cdk/core'; import { IEngine } from './engine'; -import { calculateParameterGroupFamily, ParameterGroupFamilyMapping } from './private/parameter-group-family-mapping'; +import { EngineVersion } from './engine-version'; /** * The options passed to {@link IInstanceEngine.bind}. @@ -44,14 +43,14 @@ interface InstanceEngineBaseProps { readonly engineType: string; readonly singleUserRotationApplication: secretsmanager.SecretRotationApplication; readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication; - readonly parameterGroupFamilies?: ParameterGroupFamilyMapping[]; - readonly version?: string; + readonly version?: EngineVersion; + readonly parameterGroupFamily?: string; } abstract class InstanceEngineBase implements IInstanceEngine { public readonly engineType: string; - public readonly engineVersion?: string; - public readonly parameterGroupFamily: string; + public readonly engineVersion?: EngineVersion; + public readonly parameterGroupFamily?: string; public readonly singleUserRotationApplication: secretsmanager.SecretRotationApplication; public readonly multiUserRotationApplication: secretsmanager.SecretRotationApplication; @@ -60,11 +59,8 @@ abstract class InstanceEngineBase implements IInstanceEngine { this.singleUserRotationApplication = props.singleUserRotationApplication; this.multiUserRotationApplication = props.multiUserRotationApplication; this.engineVersion = props.version; - const parameterGroupFamily = calculateParameterGroupFamily(props.parameterGroupFamilies, props.version); - if (parameterGroupFamily === undefined) { - throw new Error(`No parameter group family found for database engine ${this.engineType} with version ${this.engineVersion}.`); - } - this.parameterGroupFamily = parameterGroupFamily; + this.parameterGroupFamily = props.parameterGroupFamily ?? + (this.engineVersion ? `${this.engineType}${this.engineVersion.majorVersion}` : undefined); } public bindToInstance(_scope: core.Construct, options: InstanceEngineBindOptions): InstanceEngineConfig { @@ -76,122 +72,648 @@ abstract class InstanceEngineBase implements IInstanceEngine { } } -/** Common properties of all instance engines. */ -interface InstanceEngineProps { +/** + * The versions for the MariaDB instance engines + * (those returned by {@link DatabaseInstanceEngine.mariaDb}). + */ +export class MariaDbEngineVersion { + /** Version "10.0" (only a major version, without a specific minor version). */ + public static readonly VER_10_0 = MariaDbEngineVersion.of('10.0', '10.0'); + /** Version "10.0.17". */ + public static readonly VER_10_0_17 = MariaDbEngineVersion.of('10.0.17', '10.0'); + /** Version "10.0.24". */ + public static readonly VER_10_0_24 = MariaDbEngineVersion.of('10.0.24', '10.0'); + /** Version "10.0.28". */ + public static readonly VER_10_0_28 = MariaDbEngineVersion.of('10.0.28', '10.0'); + /** Version "10.0.31". */ + public static readonly VER_10_0_31 = MariaDbEngineVersion.of('10.0.31', '10.0'); + /** Version "10.0.32". */ + public static readonly VER_10_0_32 = MariaDbEngineVersion.of('10.0.32', '10.0'); + /** Version "10.0.34". */ + public static readonly VER_10_0_34 = MariaDbEngineVersion.of('10.0.34', '10.0'); + /** Version "10.0.35". */ + public static readonly VER_10_0_35 = MariaDbEngineVersion.of('10.0.35', '10.0'); + + /** Version "10.1" (only a major version, without a specific minor version). */ + public static readonly VER_10_1 = MariaDbEngineVersion.of('10.1', '10.1'); + /** Version "10.1.14". */ + public static readonly VER_10_1_14 = MariaDbEngineVersion.of('10.1.14', '10.1'); + /** Version "10.1.19". */ + public static readonly VER_10_1_19 = MariaDbEngineVersion.of('10.1.19', '10.1'); + /** Version "10.1.23". */ + public static readonly VER_10_1_23 = MariaDbEngineVersion.of('10.1.23', '10.1'); + /** Version "10.1.26". */ + public static readonly VER_10_1_26 = MariaDbEngineVersion.of('10.1.26', '10.1'); + /** Version "10.1.31". */ + public static readonly VER_10_1_31 = MariaDbEngineVersion.of('10.1.31', '10.1'); + /** Version "10.1.34". */ + public static readonly VER_10_1_34 = MariaDbEngineVersion.of('10.1.34', '10.1'); + + /** Version "10.2" (only a major version, without a specific minor version). */ + public static readonly VER_10_2 = MariaDbEngineVersion.of('10.2', '10.2'); + /** Version "10.2.11". */ + public static readonly VER_10_2_11 = MariaDbEngineVersion.of('10.2.11', '10.2'); + /** Version "10.2.12". */ + public static readonly VER_10_2_12 = MariaDbEngineVersion.of('10.2.12', '10.2'); + /** Version "10.2.15". */ + public static readonly VER_10_2_15 = MariaDbEngineVersion.of('10.2.15', '10.2'); + /** Version "10.2.21". */ + public static readonly VER_10_2_21 = MariaDbEngineVersion.of('10.2.21', '10.2'); + + /** Version "10.3" (only a major version, without a specific minor version). */ + public static readonly VER_10_3 = MariaDbEngineVersion.of('10.3', '10.3'); + /** Version "10.3.8". */ + public static readonly VER_10_3_8 = MariaDbEngineVersion.of('10.3.8', '10.3'); + /** Version "10.3.13". */ + public static readonly VER_10_3_13 = MariaDbEngineVersion.of('10.3.13', '10.3'); + /** Version "10.3.20". */ + public static readonly VER_10_3_20 = MariaDbEngineVersion.of('10.3.20', '10.3'); + /** Version "10.3.23". */ + public static readonly VER_10_3_23 = MariaDbEngineVersion.of('10.3.23', '10.3'); + + /** Version "10.4" (only a major version, without a specific minor version). */ + public static readonly VER_10_4 = MariaDbEngineVersion.of('10.4', '10.4'); + /** Version "10.4.8". */ + public static readonly VER_10_4_8 = MariaDbEngineVersion.of('10.4.8', '10.4'); + /** Version "10.4.13". */ + public static readonly VER_10_4_13 = MariaDbEngineVersion.of('10.4.13', '10.4'); + /** - * The exact version of the engine to use. + * Create a new MariaDbEngineVersion with an arbitrary version. * - * @default - no version specified + * @param mariaDbFullVersion the full version string, + * for example "10.5.28" + * @param mariaDbMajorVersion the major version of the engine, + * for example "10.5" */ - readonly version?: string; + public static of(mariaDbFullVersion: string, mariaDbMajorVersion: string): MariaDbEngineVersion { + return new MariaDbEngineVersion(mariaDbFullVersion, mariaDbMajorVersion); + } + + /** The full version string, for example, "10.5.28". */ + public readonly mariaDbFullVersion: string; + /** The major version of the engine, for example, "10.5". */ + public readonly mariaDbMajorVersion: string; + + private constructor(mariaDbFullVersion: string, mariaDbMajorVersion: string) { + this.mariaDbFullVersion = mariaDbFullVersion; + this.mariaDbMajorVersion = mariaDbMajorVersion; + } } /** * Properties for MariaDB instance engines. * Used in {@link DatabaseInstanceEngine.mariaDb}. */ -export interface MariaDbInstanceEngineProps extends InstanceEngineProps { +export interface MariaDbInstanceEngineProps { + /** The exact version of the engine to use. */ + readonly version: MariaDbEngineVersion; } class MariaDbInstanceEngine extends InstanceEngineBase { - constructor(props: MariaDbInstanceEngineProps = {}) { + constructor(version?: MariaDbEngineVersion) { super({ engineType: 'mariadb', singleUserRotationApplication: secretsmanager.SecretRotationApplication.MARIADB_ROTATION_SINGLE_USER, multiUserRotationApplication: secretsmanager.SecretRotationApplication.MARIADB_ROTATION_MULTI_USER, - parameterGroupFamilies: [ - { engineMajorVersion: '10.0', parameterGroupFamily: 'mariadb10.0' }, - { engineMajorVersion: '10.1', parameterGroupFamily: 'mariadb10.1' }, - { engineMajorVersion: '10.2', parameterGroupFamily: 'mariadb10.2' }, - { engineMajorVersion: '10.3', parameterGroupFamily: 'mariadb10.3' }, - ], - version: props.version, + version: version + ? { + fullVersion: version.mariaDbFullVersion, + majorVersion: version.mariaDbMajorVersion, + } + : undefined, }); } } +/** + * The versions for the MySQL instance engines + * (those returned by {@link DatabaseInstanceEngine.mysql}). + */ +export class MysqlEngineVersion { + /** Version "5.5" (only a major version, without a specific minor version). */ + public static readonly VER_5_5 = MysqlEngineVersion.of('5.5', '5.5'); + /** Version "5.5.46". */ + public static readonly VER_5_5_46 = MysqlEngineVersion.of('5.5.46', '5.5'); + /** Version "5.5.53". */ + public static readonly VER_5_5_53 = MysqlEngineVersion.of('5.5.53', '5.5'); + /** Version "5.5.57". */ + public static readonly VER_5_5_57 = MysqlEngineVersion.of('5.5.57', '5.5'); + /** Version "5.5.59". */ + public static readonly VER_5_5_59 = MysqlEngineVersion.of('5.5.59', '5.5'); + /** Version "5.5.61". */ + public static readonly VER_5_5_61 = MysqlEngineVersion.of('5.5.61', '5.5'); + + /** Version "5.6" (only a major version, without a specific minor version). */ + public static readonly VER_5_6 = MysqlEngineVersion.of('5.6', '5.6'); + /** Version "5.6.34". */ + public static readonly VER_5_6_34 = MysqlEngineVersion.of('5.6.34', '5.6'); + /** Version "5.6.35". */ + public static readonly VER_5_6_35 = MysqlEngineVersion.of('5.6.35', '5.6'); + /** Version "5.6.37". */ + public static readonly VER_5_6_37 = MysqlEngineVersion.of('5.6.37', '5.6'); + /** Version "5.6.39". */ + public static readonly VER_5_6_39 = MysqlEngineVersion.of('5.6.39', '5.6'); + /** Version "5.6.40". */ + public static readonly VER_5_6_40 = MysqlEngineVersion.of('5.6.40', '5.6'); + /** Version "5.6.41". */ + public static readonly VER_5_6_41 = MysqlEngineVersion.of('5.6.41', '5.6'); + /** Version "5.6.43". */ + public static readonly VER_5_6_43 = MysqlEngineVersion.of('5.6.43', '5.6'); + /** Version "5.6.44". */ + public static readonly VER_5_6_44 = MysqlEngineVersion.of('5.6.44', '5.6'); + /** Version "5.6.46". */ + public static readonly VER_5_6_46 = MysqlEngineVersion.of('5.6.46', '5.6'); + /** Version "5.6.48". */ + public static readonly VER_5_6_48 = MysqlEngineVersion.of('5.6.48', '5.6'); + + /** Version "5.7" (only a major version, without a specific minor version). */ + public static readonly VER_5_7 = MysqlEngineVersion.of('5.7', '5.7'); + /** Version "5.7.16". */ + public static readonly VER_5_7_16 = MysqlEngineVersion.of('5.7.16', '5.7'); + /** Version "5.7.17". */ + public static readonly VER_5_7_17 = MysqlEngineVersion.of('5.7.17', '5.7'); + /** Version "5.7.19". */ + public static readonly VER_5_7_19 = MysqlEngineVersion.of('5.7.19', '5.7'); + /** Version "5.7.21". */ + public static readonly VER_5_7_21 = MysqlEngineVersion.of('5.7.21', '5.7'); + /** Version "5.7.22". */ + public static readonly VER_5_7_22 = MysqlEngineVersion.of('5.7.22', '5.7'); + /** Version "5.7.23". */ + public static readonly VER_5_7_23 = MysqlEngineVersion.of('5.7.23', '5.7'); + /** Version "5.7.24". */ + public static readonly VER_5_7_24 = MysqlEngineVersion.of('5.7.24', '5.7'); + /** Version "5.7.25". */ + public static readonly VER_5_7_25 = MysqlEngineVersion.of('5.7.25', '5.7'); + /** Version "5.7.26". */ + public static readonly VER_5_7_26 = MysqlEngineVersion.of('5.7.26', '5.7'); + /** Version "5.7.28". */ + public static readonly VER_5_7_28 = MysqlEngineVersion.of('5.7.28', '5.7'); + /** Version "5.7.30". */ + public static readonly VER_5_7_30 = MysqlEngineVersion.of('5.7.30', '5.7'); + + /** Version "8.0" (only a major version, without a specific minor version). */ + public static readonly VER_8_0 = MysqlEngineVersion.of('8.0', '8.0'); + /** Version "8.0.11". */ + public static readonly VER_8_0_11 = MysqlEngineVersion.of('8.0.11', '8.0'); + /** Version "8.0.13". */ + public static readonly VER_8_0_13 = MysqlEngineVersion.of('8.0.13', '8.0'); + /** Version "8.0.15". */ + public static readonly VER_8_0_15 = MysqlEngineVersion.of('8.0.15', '8.0'); + /** Version "8.0.16". */ + public static readonly VER_8_0_16 = MysqlEngineVersion.of('8.0.16', '8.0'); + /** Version "8.0.17". */ + public static readonly VER_8_0_17 = MysqlEngineVersion.of('8.0.17', '8.0'); + /** Version "8.0.19". */ + public static readonly VER_8_0_19 = MysqlEngineVersion.of('8.0.19', '8.0'); + + /** + * Create a new MysqlEngineVersion with an arbitrary version. + * + * @param mysqlFullVersion the full version string, + * for example "8.1.43" + * @param mysqlMajorVersion the major version of the engine, + * for example "8.1" + */ + public static of(mysqlFullVersion: string, mysqlMajorVersion: string): MysqlEngineVersion { + return new MysqlEngineVersion(mysqlFullVersion, mysqlMajorVersion); + } + + /** The full version string, for example, "10.5.28". */ + public readonly mysqlFullVersion: string; + /** The major version of the engine, for example, "10.5". */ + public readonly mysqlMajorVersion: string; + + private constructor(mysqlFullVersion: string, mysqlMajorVersion: string) { + this.mysqlFullVersion = mysqlFullVersion; + this.mysqlMajorVersion = mysqlMajorVersion; + } +} + /** * Properties for MySQL instance engines. * Used in {@link DatabaseInstanceEngine.mysql}. */ -export interface MySqlInstanceEngineProps extends InstanceEngineProps { +export interface MySqlInstanceEngineProps { + /** The exact version of the engine to use. */ + readonly version: MysqlEngineVersion; } class MySqlInstanceEngine extends InstanceEngineBase { - constructor(props: MySqlInstanceEngineProps = {}) { + constructor(version?: MysqlEngineVersion) { super({ engineType: 'mysql', singleUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_SINGLE_USER, multiUserRotationApplication: secretsmanager.SecretRotationApplication.MYSQL_ROTATION_MULTI_USER, - parameterGroupFamilies: [ - { engineMajorVersion: '5.6', parameterGroupFamily: 'mysql5.6' }, - { engineMajorVersion: '5.7', parameterGroupFamily: 'mysql5.7' }, - { engineMajorVersion: '8.0', parameterGroupFamily: 'mysql8.0' }, - ], - version: props.version, + version: version + ? { + fullVersion: version.mysqlFullVersion, + majorVersion: version.mysqlMajorVersion, + } + : undefined, }); } } +/** + * The versions for the PostgreSQL instance engines + * (those returned by {@link DatabaseInstanceEngine.postgres}). + */ +export class PostgresEngineVersion { + /** Version "9.5" (only a major version, without a specific minor version). */ + public static readonly VER_9_5 = PostgresEngineVersion.of('9.5', '9.5'); + /** Version "9.5.2". */ + public static readonly VER_9_5_2 = PostgresEngineVersion.of('9.5.2', '9.5'); + /** Version "9.5.4". */ + public static readonly VER_9_5_4 = PostgresEngineVersion.of('9.5.4', '9.5'); + /** Version "9.5.6". */ + public static readonly VER_9_5_6 = PostgresEngineVersion.of('9.5.6', '9.5'); + /** Version "9.5.7". */ + public static readonly VER_9_5_7 = PostgresEngineVersion.of('9.5.7', '9.5'); + /** Version "9.5.9". */ + public static readonly VER_9_5_9 = PostgresEngineVersion.of('9.5.9', '9.5'); + /** Version "9.5.10". */ + public static readonly VER_9_5_10 = PostgresEngineVersion.of('9.5.10', '9.5'); + /** Version "9.5.12". */ + public static readonly VER_9_5_12 = PostgresEngineVersion.of('9.5.12', '9.5'); + /** Version "9.5.13". */ + public static readonly VER_9_5_13 = PostgresEngineVersion.of('9.5.13', '9.5'); + /** Version "9.5.14". */ + public static readonly VER_9_5_14 = PostgresEngineVersion.of('9.5.14', '9.5'); + /** Version "9.5.15". */ + public static readonly VER_9_5_15 = PostgresEngineVersion.of('9.5.15', '9.5'); + /** Version "9.5.16". */ + public static readonly VER_9_5_16 = PostgresEngineVersion.of('9.5.16', '9.5'); + /** Version "9.5.18". */ + public static readonly VER_9_5_18 = PostgresEngineVersion.of('9.5.18', '9.5'); + /** Version "9.5.19". */ + public static readonly VER_9_5_19 = PostgresEngineVersion.of('9.5.19', '9.5'); + /** Version "9.5.20". */ + public static readonly VER_9_5_20 = PostgresEngineVersion.of('9.5.20', '9.5'); + /** Version "9.5.21". */ + public static readonly VER_9_5_21 = PostgresEngineVersion.of('9.5.21', '9.5'); + /** Version "9.5.22". */ + public static readonly VER_9_5_22 = PostgresEngineVersion.of('9.5.22', '9.5'); + + /** Version "9.6" (only a major version, without a specific minor version). */ + public static readonly VER_9_6 = PostgresEngineVersion.of('9.6', '9.6'); + /** Version "9.6.1". */ + public static readonly VER_9_6_1 = PostgresEngineVersion.of('9.6.1', '9.6'); + /** Version "9.6.2". */ + public static readonly VER_9_6_2 = PostgresEngineVersion.of('9.6.2', '9.6'); + /** Version "9.6.3". */ + public static readonly VER_9_6_3 = PostgresEngineVersion.of('9.6.3', '9.6'); + /** Version "9.6.5". */ + public static readonly VER_9_6_5 = PostgresEngineVersion.of('9.6.5', '9.6'); + /** Version "9.6.6". */ + public static readonly VER_9_6_6 = PostgresEngineVersion.of('9.6.6', '9.6'); + /** Version "9.6.8". */ + public static readonly VER_9_6_8 = PostgresEngineVersion.of('9.6.8', '9.6'); + /** Version "9.6.9". */ + public static readonly VER_9_6_9 = PostgresEngineVersion.of('9.6.9', '9.6'); + /** Version "9.6.10". */ + public static readonly VER_9_6_10 = PostgresEngineVersion.of('9.6.10', '9.6'); + /** Version "9.6.11". */ + public static readonly VER_9_6_11 = PostgresEngineVersion.of('9.6.11', '9.6'); + /** Version "9.6.12". */ + public static readonly VER_9_6_12 = PostgresEngineVersion.of('9.6.12', '9.6'); + /** Version "9.6.14". */ + public static readonly VER_9_6_14 = PostgresEngineVersion.of('9.6.14', '9.6'); + /** Version "9.6.15". */ + public static readonly VER_9_6_15 = PostgresEngineVersion.of('9.6.15', '9.6'); + /** Version "9.6.16". */ + public static readonly VER_9_6_16 = PostgresEngineVersion.of('9.6.16', '9.6'); + /** Version "9.6.17". */ + public static readonly VER_9_6_17 = PostgresEngineVersion.of('9.6.17', '9.6'); + /** Version "9.6.18". */ + public static readonly VER_9_6_18 = PostgresEngineVersion.of('9.6.18', '9.6'); + + /** Version "10" (only a major version, without a specific minor version). */ + public static readonly VER_10 = PostgresEngineVersion.of('10', '10'); + /** Version "10.1". */ + public static readonly VER_10_1 = PostgresEngineVersion.of('10.1', '10'); + /** Version "10.3". */ + public static readonly VER_10_3 = PostgresEngineVersion.of('10.3', '10'); + /** Version "10.4". */ + public static readonly VER_10_4 = PostgresEngineVersion.of('10.4', '10'); + /** Version "10.5". */ + public static readonly VER_10_5 = PostgresEngineVersion.of('10.5', '10'); + /** Version "10.6". */ + public static readonly VER_10_6 = PostgresEngineVersion.of('10.6', '10'); + /** Version "10.7". */ + public static readonly VER_10_7 = PostgresEngineVersion.of('10.7', '10'); + /** Version "10.9". */ + public static readonly VER_10_9 = PostgresEngineVersion.of('10.9', '10'); + /** Version "10.10". */ + public static readonly VER_10_10 = PostgresEngineVersion.of('10.10', '10'); + /** Version "10.11". */ + public static readonly VER_10_11 = PostgresEngineVersion.of('10.11', '10'); + /** Version "10.12". */ + public static readonly VER_10_12 = PostgresEngineVersion.of('10.12', '10'); + /** Version "10.13". */ + public static readonly VER_10_13 = PostgresEngineVersion.of('10.13', '10'); + + /** Version "11" (only a major version, without a specific minor version). */ + public static readonly VER_11 = PostgresEngineVersion.of('11', '11'); + /** Version "11.1". */ + public static readonly VER_11_1 = PostgresEngineVersion.of('11.1', '11'); + /** Version "11.2". */ + public static readonly VER_11_2 = PostgresEngineVersion.of('11.2', '11'); + /** Version "11.4". */ + public static readonly VER_11_4 = PostgresEngineVersion.of('11.4', '11'); + /** Version "11.5". */ + public static readonly VER_11_5 = PostgresEngineVersion.of('11.5', '11'); + /** Version "11.6". */ + public static readonly VER_11_6 = PostgresEngineVersion.of('11.6', '11'); + /** Version "11.7". */ + public static readonly VER_11_7 = PostgresEngineVersion.of('11.7', '11'); + /** Version "11.8". */ + public static readonly VER_11_8 = PostgresEngineVersion.of('11.8', '11'); + + /** Version "12" (only a major version, without a specific minor version). */ + public static readonly VER_12 = PostgresEngineVersion.of('12', '12'); + /** Version "12.2". */ + public static readonly VER_12_2 = PostgresEngineVersion.of('12.2', '12'); + /** Version "12.3". */ + public static readonly VER_12_3 = PostgresEngineVersion.of('12.3', '12'); + + /** + * Create a new PostgresEngineVersion with an arbitrary version. + * + * @param postgresFullVersion the full version string, + * for example "13.11" + * @param postgresMajorVersion the major version of the engine, + * for example "13" + */ + public static of(postgresFullVersion: string, postgresMajorVersion: string): PostgresEngineVersion { + return new PostgresEngineVersion(postgresFullVersion, postgresMajorVersion); + } + + /** The full version string, for example, "13.11". */ + public readonly postgresFullVersion: string; + /** The major version of the engine, for example, "13". */ + public readonly postgresMajorVersion: string; + + private constructor(postgresFullVersion: string, postgresMajorVersion: string) { + this.postgresFullVersion = postgresFullVersion; + this.postgresMajorVersion = postgresMajorVersion; + } +} + /** * Properties for PostgreSQL instance engines. * Used in {@link DatabaseInstanceEngine.postgres}. */ -export interface PostgresInstanceEngineProps extends InstanceEngineProps { +export interface PostgresInstanceEngineProps { + /** The exact version of the engine to use. */ + readonly version: PostgresEngineVersion; } /** * The instance engine for PostgreSQL. */ class PostgresInstanceEngine extends InstanceEngineBase { - constructor(props: PostgresInstanceEngineProps = {}) { + constructor(version?: PostgresEngineVersion) { super({ engineType: 'postgres', singleUserRotationApplication: secretsmanager.SecretRotationApplication.POSTGRES_ROTATION_SINGLE_USER, multiUserRotationApplication: secretsmanager.SecretRotationApplication.POSTGRES_ROTATION_MULTI_USER, - parameterGroupFamilies: [ - { engineMajorVersion: '9.3', parameterGroupFamily: 'postgres9.3' }, - { engineMajorVersion: '9.4', parameterGroupFamily: 'postgres9.4' }, - { engineMajorVersion: '9.5', parameterGroupFamily: 'postgres9.5' }, - { engineMajorVersion: '9.6', parameterGroupFamily: 'postgres9.6' }, - { engineMajorVersion: '10', parameterGroupFamily: 'postgres10' }, - { engineMajorVersion: '11', parameterGroupFamily: 'postgres11' }, - ], - version: props.version, + version: version + ? { + fullVersion: version.postgresFullVersion, + majorVersion: version.postgresMajorVersion, + } + : undefined, }); } } -interface OracleInstanceEngineProps extends InstanceEngineProps { +/** + * The versions for the legacy Oracle instance engines + * (those returned by {@link DatabaseInstanceEngine.oracleSe} + * and {@link DatabaseInstanceEngine.oracleSe1}). + * Note: RDS will stop allowing creating new databases with this version in August 2020. + */ +export class OracleLegacyEngineVersion { + /** Version "11.2" (only a major version, without a specific minor version). */ + public static readonly VER_11_2 = OracleLegacyEngineVersion.of('11.2', '11.2'); + /** Version "11.2.0.2.v2". */ + public static readonly VER_11_2_0_2_V2 = OracleLegacyEngineVersion.of('11.2.0.2.v2', '11.2'); + /** Version "11.2.0.4.v1". */ + public static readonly VER_11_2_0_4_V1 = OracleLegacyEngineVersion.of('11.2.0.4.v1', '11.2'); + /** Version "11.2.0.4.v3". */ + public static readonly VER_11_2_0_4_V3 = OracleLegacyEngineVersion.of('11.2.0.4.v3', '11.2'); + /** Version "11.2.0.4.v4". */ + public static readonly VER_11_2_0_4_V4 = OracleLegacyEngineVersion.of('11.2.0.4.v4', '11.2'); + /** Version "11.2.0.4.v5". */ + public static readonly VER_11_2_0_4_V5 = OracleLegacyEngineVersion.of('11.2.0.4.v5', '11.2'); + /** Version "11.2.0.4.v6". */ + public static readonly VER_11_2_0_4_V6 = OracleLegacyEngineVersion.of('11.2.0.4.v6', '11.2'); + /** Version "11.2.0.4.v7". */ + public static readonly VER_11_2_0_4_V7 = OracleLegacyEngineVersion.of('11.2.0.4.v7', '11.2'); + /** Version "11.2.0.4.v8". */ + public static readonly VER_11_2_0_4_V8 = OracleLegacyEngineVersion.of('11.2.0.4.v8', '11.2'); + /** Version "11.2.0.4.v9". */ + public static readonly VER_11_2_0_4_V9 = OracleLegacyEngineVersion.of('11.2.0.4.v9', '11.2'); + /** Version "11.2.0.4.v10". */ + public static readonly VER_11_2_0_4_V10 = OracleLegacyEngineVersion.of('11.2.0.4.v10', '11.2'); + /** Version "11.2.0.4.v11". */ + public static readonly VER_11_2_0_4_V11 = OracleLegacyEngineVersion.of('11.2.0.4.v11', '11.2'); + /** Version "11.2.0.4.v12". */ + public static readonly VER_11_2_0_4_V12 = OracleLegacyEngineVersion.of('11.2.0.4.v12', '11.2'); + /** Version "11.2.0.4.v13". */ + public static readonly VER_11_2_0_4_V13 = OracleLegacyEngineVersion.of('11.2.0.4.v13', '11.2'); + /** Version "11.2.0.4.v14". */ + public static readonly VER_11_2_0_4_V14 = OracleLegacyEngineVersion.of('11.2.0.4.v14', '11.2'); + /** Version "11.2.0.4.v15". */ + public static readonly VER_11_2_0_4_V15 = OracleLegacyEngineVersion.of('11.2.0.4.v15', '11.2'); + /** Version "11.2.0.4.v16". */ + public static readonly VER_11_2_0_4_V16 = OracleLegacyEngineVersion.of('11.2.0.4.v16', '11.2'); + /** Version "11.2.0.4.v17". */ + public static readonly VER_11_2_0_4_V17 = OracleLegacyEngineVersion.of('11.2.0.4.v17', '11.2'); + /** Version "11.2.0.4.v18". */ + public static readonly VER_11_2_0_4_V18 = OracleLegacyEngineVersion.of('11.2.0.4.v18', '11.2'); + /** Version "11.2.0.4.v19". */ + public static readonly VER_11_2_0_4_V19 = OracleLegacyEngineVersion.of('11.2.0.4.v19', '11.2'); + /** Version "11.2.0.4.v20". */ + public static readonly VER_11_2_0_4_V20 = OracleLegacyEngineVersion.of('11.2.0.4.v20', '11.2'); + /** Version "11.2.0.4.v21". */ + public static readonly VER_11_2_0_4_V21 = OracleLegacyEngineVersion.of('11.2.0.4.v21', '11.2'); + /** Version "11.2.0.4.v22". */ + public static readonly VER_11_2_0_4_V22 = OracleLegacyEngineVersion.of('11.2.0.4.v22', '11.2'); + /** Version "11.2.0.4.v23". */ + public static readonly VER_11_2_0_4_V23 = OracleLegacyEngineVersion.of('11.2.0.4.v23', '11.2'); + /** Version "11.2.0.4.v24". */ + public static readonly VER_11_2_0_4_V24 = OracleLegacyEngineVersion.of('11.2.0.4.v24', '11.2'); + + private static of(oracleLegacyFullVersion: string, oracleLegacyMajorVersion: string): OracleLegacyEngineVersion { + return new OracleLegacyEngineVersion(oracleLegacyFullVersion, oracleLegacyMajorVersion); + } + + /** The full version string, for example, "11.2.0.4.v24". */ + public readonly oracleLegacyFullVersion: string; + /** The major version of the engine, for example, "11.2". */ + public readonly oracleLegacyMajorVersion: string; + + private constructor(oracleLegacyFullVersion: string, oracleLegacyMajorVersion: string) { + this.oracleLegacyFullVersion = oracleLegacyFullVersion; + this.oracleLegacyMajorVersion = oracleLegacyMajorVersion; + } +} + +/** + * The versions for the Oracle instance engines + * (those returned by {@link DatabaseInstanceEngine.oracleSe2} and + * {@link DatabaseInstanceEngine.oracleEe}). + */ +export class OracleEngineVersion { + /** Version "12.1" (only a major version, without a specific minor version). */ + public static readonly VER_12_1 = OracleEngineVersion.of('12.1', '12.1'); + /** Version "12.1.0.2.v1". */ + public static readonly VER_12_1_0_2_V1 = OracleEngineVersion.of('12.1.0.2.v1', '12.1'); + /** Version "12.1.0.2.v2". */ + public static readonly VER_12_1_0_2_V2 = OracleEngineVersion.of('12.1.0.2.v2', '12.1'); + /** Version "12.1.0.2.v3". */ + public static readonly VER_12_1_0_2_V3 = OracleEngineVersion.of('12.1.0.2.v3', '12.1'); + /** Version "12.1.0.2.v4". */ + public static readonly VER_12_1_0_2_V4 = OracleEngineVersion.of('12.1.0.2.v4', '12.1'); + /** Version "12.1.0.2.v5". */ + public static readonly VER_12_1_0_2_V5 = OracleEngineVersion.of('12.1.0.2.v5', '12.1'); + /** Version "12.1.0.2.v6". */ + public static readonly VER_12_1_0_2_V6 = OracleEngineVersion.of('12.1.0.2.v6', '12.1'); + /** Version "12.1.0.2.v7". */ + public static readonly VER_12_1_0_2_V7 = OracleEngineVersion.of('12.1.0.2.v7', '12.1'); + /** Version "12.1.0.2.v8". */ + public static readonly VER_12_1_0_2_V8 = OracleEngineVersion.of('12.1.0.2.v8', '12.1'); + /** Version "12.1.0.2.v9". */ + public static readonly VER_12_1_0_2_V9 = OracleEngineVersion.of('12.1.0.2.v9', '12.1'); + /** Version "12.1.0.2.v10". */ + public static readonly VER_12_1_0_2_V10 = OracleEngineVersion.of('12.1.0.2.v10', '12.1'); + /** Version "12.1.0.2.v11". */ + public static readonly VER_12_1_0_2_V11 = OracleEngineVersion.of('12.1.0.2.v11', '12.1'); + /** Version "12.1.0.2.v12". */ + public static readonly VER_12_1_0_2_V12 = OracleEngineVersion.of('12.1.0.2.v12', '12.1'); + /** Version "12.1.0.2.v13". */ + public static readonly VER_12_1_0_2_V13 = OracleEngineVersion.of('12.1.0.2.v13', '12.1'); + /** Version "12.1.0.2.v14". */ + public static readonly VER_12_1_0_2_V14 = OracleEngineVersion.of('12.1.0.2.v14', '12.1'); + /** Version "12.1.0.2.v15". */ + public static readonly VER_12_1_0_2_V15 = OracleEngineVersion.of('12.1.0.2.v15', '12.1'); + /** Version "12.1.0.2.v16". */ + public static readonly VER_12_1_0_2_V16 = OracleEngineVersion.of('12.1.0.2.v16', '12.1'); + /** Version "12.1.0.2.v17". */ + public static readonly VER_12_1_0_2_V17 = OracleEngineVersion.of('12.1.0.2.v17', '12.1'); + /** Version "12.1.0.2.v18". */ + public static readonly VER_12_1_0_2_V18 = OracleEngineVersion.of('12.1.0.2.v18', '12.1'); + /** Version "12.1.0.2.v19". */ + public static readonly VER_12_1_0_2_V19 = OracleEngineVersion.of('12.1.0.2.v19', '12.1'); + /** Version "12.1.0.2.v20". */ + public static readonly VER_12_1_0_2_V20 = OracleEngineVersion.of('12.1.0.2.v20', '12.1'); + + /** Version "12.2" (only a major version, without a specific minor version). */ + public static readonly VER_12_2 = OracleEngineVersion.of('12.2', '12.2'); + /** Version "12.2.0.1.ru-2018-10.rur-2018-10.r1". */ + public static readonly VER_12_2_0_1_2018_10_R1 = OracleEngineVersion.of('12.2.0.1.ru-2018-10.rur-2018-10.r1', '12.2'); + /** Version "12.2.0.1.ru-2019-01.rur-2019-01.r1". */ + public static readonly VER_12_2_0_1_2019_01_R1 = OracleEngineVersion.of('12.2.0.1.ru-2019-01.rur-2019-01.r1', '12.2'); + /** Version "12.2.0.1.ru-2019-04.rur-2019-04.r1". */ + public static readonly VER_12_2_0_1_2019_04_R1 = OracleEngineVersion.of('12.2.0.1.ru-2019-04.rur-2019-04.r1', '12.2'); + /** Version "12.2.0.1.ru-2019-07.rur-2019-07.r1". */ + public static readonly VER_12_2_0_1_2019_07_R1 = OracleEngineVersion.of('12.2.0.1.ru-2019-07.rur-2019-07.r1', '12.2'); + /** Version "12.2.0.1.ru-2019-10.rur-2019-10.r1". */ + public static readonly VER_12_2_0_1_2019_10_R1 = OracleEngineVersion.of('12.2.0.1.ru-2019-10.rur-2019-10.r1', '12.2'); + /** Version "12.2.0.1.ru-2020-01.rur-2020-01.r1". */ + public static readonly VER_12_2_0_1_2020_01_R1 = OracleEngineVersion.of('12.2.0.1.ru-2020-01.rur-2020-01.r1', '12.2'); + /** Version "12.2.0.1.ru-2020-04.rur-2020-04.r1". */ + public static readonly VER_12_2_0_1_2020_04_R1 = OracleEngineVersion.of('12.2.0.1.ru-2020-04.rur-2020-04.r1', '12.2'); + + /** Version "18" (only a major version, without a specific minor version). */ + public static readonly VER_18 = OracleEngineVersion.of('18', '18'); + /** Version "18.0.0.0.ru-2019-07.rur-2019-07.r1". */ + public static readonly VER_18_0_0_0_2019_07_R1 = OracleEngineVersion.of('18.0.0.0.ru-2019-07.rur-2019-07.r1', '18'); + /** Version "18.0.0.0.ru-2019-10.rur-2019-10.r1". */ + public static readonly VER_18_0_0_0_2019_10_R1 = OracleEngineVersion.of('18.0.0.0.ru-2019-10.rur-2019-10.r1', '18'); + /** Version "18.0.0.0.ru-2020-01.rur-2020-01.r1". */ + public static readonly VER_18_0_0_0_2020_01_R1 = OracleEngineVersion.of('18.0.0.0.ru-2020-01.rur-2020-01.r1', '18'); + /** Version "18.0.0.0.ru-2020-04.rur-2020-04.r1". */ + public static readonly VER_18_0_0_0_2020_04_R1 = OracleEngineVersion.of('18.0.0.0.ru-2020-04.rur-2020-04.r1', '18'); + + /** Version "19" (only a major version, without a specific minor version). */ + public static readonly VER_19 = OracleEngineVersion.of('19', '19'); + /** Version "19.0.0.0.ru-2019-07.rur-2019-07.r1". */ + public static readonly VER_19_0_0_0_2019_07_R1 = OracleEngineVersion.of('19.0.0.0.ru-2019-07.rur-2019-07.r1', '19'); + /** Version "19.0.0.0.ru-2019-10.rur-2019-10.r1". */ + public static readonly VER_19_0_0_0_2019_10_R1 = OracleEngineVersion.of('19.0.0.0.ru-2019-10.rur-2019-10.r1', '19'); + /** Version "19.0.0.0.ru-2020-01.rur-2020-01.r1". */ + public static readonly VER_19_0_0_0_2020_01_R1 = OracleEngineVersion.of('19.0.0.0.ru-2020-01.rur-2020-01.r1', '19'); + /** Version "19.0.0.0.ru-2020-04.rur-2020-04.r1". */ + public static readonly VER_19_0_0_0_2020_04_R1 = OracleEngineVersion.of('19.0.0.0.ru-2020-04.rur-2020-04.r1', '19'); + + /** + * Creates a new OracleEngineVersion with an arbitrary version. + * + * @param oracleFullVersion the full version string, + * for example "19.0.0.0.ru-2019-10.rur-2019-10.r1" + * @param oracleMajorVersion the major version of the engine, + * for example "19" + */ + public static of(oracleFullVersion: string, oracleMajorVersion: string): OracleEngineVersion { + return new OracleEngineVersion(oracleFullVersion, oracleMajorVersion); + } + + /** The full version string, for example, "19.0.0.0.ru-2019-10.rur-2019-10.r1". */ + public readonly oracleFullVersion: string; + /** The major version of the engine, for example, "19". */ + public readonly oracleMajorVersion: string; + + private constructor(oracleFullVersion: string, oracleMajorVersion: string) { + this.oracleFullVersion = oracleFullVersion; + this.oracleMajorVersion = oracleMajorVersion; + } +} + +interface OracleInstanceEngineBaseProps { readonly engineType: string; - readonly parameterGroupFamilies?: ParameterGroupFamilyMapping[]; + readonly version?: EngineVersion; } -abstract class OracleInstanceEngine extends InstanceEngineBase { - constructor(props: OracleInstanceEngineProps) { +abstract class OracleInstanceEngineBase extends InstanceEngineBase { + constructor(props: OracleInstanceEngineBaseProps) { super({ ...props, singleUserRotationApplication: secretsmanager.SecretRotationApplication.ORACLE_ROTATION_SINGLE_USER, multiUserRotationApplication: secretsmanager.SecretRotationApplication.ORACLE_ROTATION_MULTI_USER, + parameterGroupFamily: props.version ? `${props.engineType}-${props.version.majorVersion}` : undefined, }); } } +interface OracleInstanceEngineProps { + /** The exact version of the engine to use. */ + readonly version: OracleEngineVersion; +} + /** * Properties for Oracle Standard Edition instance engines. * Used in {@link DatabaseInstanceEngine.oracleSe}. */ -export interface OracleSeInstanceEngineProps extends InstanceEngineProps { +export interface OracleSeInstanceEngineProps { + /** The exact version of the engine to use. */ + readonly version: OracleLegacyEngineVersion; } -class OracleSeInstanceEngine extends OracleInstanceEngine { - constructor(props: OracleSeInstanceEngineProps = {}) { +class OracleSeInstanceEngine extends OracleInstanceEngineBase { + constructor(version?: OracleLegacyEngineVersion) { super({ engineType: 'oracle-se', - parameterGroupFamilies: [ - { engineMajorVersion: '11.2', parameterGroupFamily: 'oracle-se-11.2' }, - ], - version: props.version, + version: version + ? { + fullVersion: version.oracleLegacyFullVersion, + majorVersion: version.oracleLegacyMajorVersion, + } + : { + majorVersion: '11.2', + }, }); } } @@ -200,17 +722,23 @@ class OracleSeInstanceEngine extends OracleInstanceEngine { * Properties for Oracle Standard Edition 1 instance engines. * Used in {@link DatabaseInstanceEngine.oracleSe1}. */ -export interface OracleSe1InstanceEngineProps extends InstanceEngineProps { +export interface OracleSe1InstanceEngineProps { + /** The exact version of the engine to use. */ + readonly version: OracleLegacyEngineVersion; } -class OracleSe1InstanceEngine extends OracleInstanceEngine { - constructor(props: OracleSe1InstanceEngineProps = {}) { +class OracleSe1InstanceEngine extends OracleInstanceEngineBase { + constructor(version?: OracleLegacyEngineVersion) { super({ engineType: 'oracle-se1', - parameterGroupFamilies: [ - { engineMajorVersion: '11.2', parameterGroupFamily: 'oracle-se1-11.2' }, - ], - version: props.version, + version: version + ? { + fullVersion: version.oracleLegacyFullVersion, + majorVersion: version.oracleLegacyMajorVersion, + } + : { + majorVersion: '11.2', + }, }); } } @@ -219,21 +747,19 @@ class OracleSe1InstanceEngine extends OracleInstanceEngine { * Properties for Oracle Standard Edition 2 instance engines. * Used in {@link DatabaseInstanceEngine.oracleSe2}. */ -export interface OracleSe2InstanceEngineProps extends InstanceEngineProps { +export interface OracleSe2InstanceEngineProps extends OracleInstanceEngineProps { } -class OracleSe2InstanceEngine extends OracleInstanceEngine { - constructor(props: OracleSe2InstanceEngineProps = {}) { +class OracleSe2InstanceEngine extends OracleInstanceEngineBase { + constructor(version?: OracleEngineVersion) { super({ engineType: 'oracle-se2', - parameterGroupFamilies: [ - { engineMajorVersion: '11.2', parameterGroupFamily: 'oracle-se2-11.2' }, - { engineMajorVersion: '12.1', parameterGroupFamily: 'oracle-se2-12.1' }, - { engineMajorVersion: '12.2', parameterGroupFamily: 'oracle-se2-12.2' }, - { engineMajorVersion: '18', parameterGroupFamily: 'oracle-se2-18' }, - { engineMajorVersion: '19', parameterGroupFamily: 'oracle-se2-19' }, - ], - version: props.version, + version: version + ? { + fullVersion: version.oracleFullVersion, + majorVersion: version.oracleMajorVersion, + } + : undefined, }); } } @@ -242,37 +768,138 @@ class OracleSe2InstanceEngine extends OracleInstanceEngine { * Properties for Oracle Enterprise Edition instance engines. * Used in {@link DatabaseInstanceEngine.oracleEe}. */ -export interface OracleEeInstanceEngineProps extends InstanceEngineProps { +export interface OracleEeInstanceEngineProps extends OracleInstanceEngineProps { } -class OracleEeInstanceEngine extends OracleInstanceEngine { - constructor(props: OracleEeInstanceEngineProps = {}) { +class OracleEeInstanceEngine extends OracleInstanceEngineBase { + constructor(version?: OracleEngineVersion) { super({ engineType: 'oracle-ee', - parameterGroupFamilies: [ - { engineMajorVersion: '11.2', parameterGroupFamily: 'oracle-ee-11.2' }, - { engineMajorVersion: '12.1', parameterGroupFamily: 'oracle-ee-12.1' }, - { engineMajorVersion: '12.2', parameterGroupFamily: 'oracle-ee-12.2' }, - { engineMajorVersion: '18', parameterGroupFamily: 'oracle-ee-18' }, - { engineMajorVersion: '19', parameterGroupFamily: 'oracle-ee-19' }, - ], - version: props.version, + version: version + ? { + fullVersion: version.oracleFullVersion, + majorVersion: version.oracleMajorVersion, + } + : undefined, }); } } -interface SqlServerInstanceEngineProps extends InstanceEngineProps { +/** + * The versions for the SQL Server instance engines + * (those returned by {@link DatabaseInstanceEngine.sqlServerSe}, + * {@link DatabaseInstanceEngine.sqlServerEx}, {@link DatabaseInstanceEngine.sqlServerWeb} + * and {@link DatabaseInstanceEngine.sqlServerEe}). + */ +export class SqlServerEngineVersion { + /** Version "11.0" (only a major version, without a specific minor version). */ + public static readonly VER_11 = SqlServerEngineVersion.of('11.0', '11.0'); + /** Version "11.00.5058.0.v1". */ + public static readonly VER_11_00_5058_0_V1 = SqlServerEngineVersion.of('11.00.5058.0.v1', '11.0'); + /** Version "11.00.6020.0.v1". */ + public static readonly VER_11_00_6020_0_V1 = SqlServerEngineVersion.of('11.00.6020.0.v1', '11.0'); + /** Version "11.00.6594.0.v1". */ + public static readonly VER_11_00_6594_0_V1 = SqlServerEngineVersion.of('11.00.6594.0.v1', '11.0'); + /** Version "11.00.7462.6.v1". */ + public static readonly VER_11_00_7462_6_V1 = SqlServerEngineVersion.of('11.00.7462.6.v1', '11.0'); + /** Version "11.00.7493.4.v1". */ + public static readonly VER_11_00_7493_4_V1 = SqlServerEngineVersion.of('11.00.7493.4.v1', '11.0'); + + /** Version "12.0" (only a major version, without a specific minor version). */ + public static readonly VER_12 = SqlServerEngineVersion.of('12.0', '12.0'); + /** Version "12.00.5000.0.v1". */ + public static readonly VER_12_00_5000_0_V1 = SqlServerEngineVersion.of('12.00.5000.0.v1', '12.0'); + /** Version "12.00.5546.0.v1". */ + public static readonly VER_12_00_5546_0_V1 = SqlServerEngineVersion.of('12.00.5546.0.v1', '12.0'); + /** Version "12.00.5571.0.v1". */ + public static readonly VER_12_00_5571_0_V1 = SqlServerEngineVersion.of('12.00.5571.0.v1', '12.0'); + /** Version "12.00.6293.0.v1". */ + public static readonly VER_12_00_6293_0_V1 = SqlServerEngineVersion.of('12.00.6293.0.v1', '12.0'); + /** Version "12.00.6329.1.v1". */ + public static readonly VER_12_00_6329_1_V1 = SqlServerEngineVersion.of('12.00.6329.1.v1', '12.0'); + + /** Version "13.0" (only a major version, without a specific minor version). */ + public static readonly VER_13 = SqlServerEngineVersion.of('13.0', '13.0'); + /** Version "13.00.2164.0.v1". */ + public static readonly VER_13_00_2164_0_V1 = SqlServerEngineVersion.of('13.00.2164.0.v1', '13.0'); + /** Version "13.00.4422.0.v1". */ + public static readonly VER_13_00_4422_0_V1 = SqlServerEngineVersion.of('13.00.4422.0.v1', '13.0'); + /** Version "13.00.4451.0.v1". */ + public static readonly VER_13_00_4451_0_V1 = SqlServerEngineVersion.of('13.00.4451.0.v1', '13.0'); + /** Version "13.00.4466.4.v1". */ + public static readonly VER_13_00_4466_4_V1 = SqlServerEngineVersion.of('13.00.4466.4.v1', '13.0'); + /** Version "13.00.4522.0.v1". */ + public static readonly VER_13_00_4522_0_V1 = SqlServerEngineVersion.of('13.00.4522.0.v1', '13.0'); + /** Version "13.00.5216.0.v1". */ + public static readonly VER_13_00_5216_0_V1 = SqlServerEngineVersion.of('13.00.5216.0.v1', '13.0'); + /** Version "13.00.5292.0.v1". */ + public static readonly VER_13_00_5292_0_V1 = SqlServerEngineVersion.of('13.00.5292.0.v1', '13.0'); + /** Version "13.00.5366.0.v1". */ + public static readonly VER_13_00_5366_0_V1 = SqlServerEngineVersion.of('13.00.5366.0.v1', '13.0'); + /** Version "13.00.5426.0.v1". */ + public static readonly VER_13_00_5426_0_V1 = SqlServerEngineVersion.of('13.00.5426.0.v1', '13.0'); + /** Version "13.00.5598.27.v1". */ + public static readonly VER_13_00_5598_27_V1 = SqlServerEngineVersion.of('13.00.5598.27.v1', '13.0'); + + /** Version "14.0" (only a major version, without a specific minor version). */ + public static readonly VER_14 = SqlServerEngineVersion.of('14.0', '14.0'); + /** Version "14.00.1000.169.v1". */ + public static readonly VER_14_00_1000_169_V1 = SqlServerEngineVersion.of('14.00.1000.169.v1', '14.0'); + /** Version "14.00.3015.40.v1". */ + public static readonly VER_14_00_3015_40_V1 = SqlServerEngineVersion.of('14.00.3015.40.v1', '14.0'); + /** Version "14.00.3035.2.v1". */ + public static readonly VER_14_00_3035_2_V1 = SqlServerEngineVersion.of('14.00.3035.2.v1', '14.0'); + /** Version "14.00.3049.1.v1". */ + public static readonly VER_14_00_3049_1_V1 = SqlServerEngineVersion.of('14.00.3049.1.v1', '14.0'); + /** Version "14.00.3192.2.v1". */ + public static readonly VER_14_00_3192_2_V1 = SqlServerEngineVersion.of('14.00.3192.2.v1', '14.0'); + + /** + * Create a new SqlServerEngineVersion with an arbitrary version. + * + * @param sqlServerFullVersion the full version string, + * for example "15.00.3049.1.v1" + * @param sqlServerMajorVersion the major version of the engine, + * for example "15.0" + */ + public static of(sqlServerFullVersion: string, sqlServerMajorVersion: string): SqlServerEngineVersion { + return new SqlServerEngineVersion(sqlServerFullVersion, sqlServerMajorVersion); + } + + /** The full version string, for example, "15.00.3049.1.v1". */ + public readonly sqlServerFullVersion: string; + /** The major version of the engine, for example, "15.0". */ + public readonly sqlServerMajorVersion: string; + + private constructor(sqlServerFullVersion: string, sqlServerMajorVersion: string) { + this.sqlServerFullVersion = sqlServerFullVersion; + this.sqlServerMajorVersion = sqlServerMajorVersion; + } +} + +interface SqlServerInstanceEngineProps { + /** The exact version of the engine to use. */ + readonly version: SqlServerEngineVersion; +} + +interface SqlServerInstanceEngineBaseProps { readonly engineType: string; - readonly parameterGroupFamilies?: ParameterGroupFamilyMapping[]; - readonly defaultInstanceType?: ec2.InstanceType; + readonly version?: SqlServerEngineVersion; } -abstract class SqlServerInstanceEngine extends InstanceEngineBase { - constructor(props: SqlServerInstanceEngineProps) { +abstract class SqlServerInstanceEngineBase extends InstanceEngineBase { + constructor(props: SqlServerInstanceEngineBaseProps) { super({ ...props, singleUserRotationApplication: secretsmanager.SecretRotationApplication.SQLSERVER_ROTATION_SINGLE_USER, multiUserRotationApplication: secretsmanager.SecretRotationApplication.SQLSERVER_ROTATION_MULTI_USER, + version: props.version + ? { + fullVersion: props.version.sqlServerFullVersion, + majorVersion: props.version.sqlServerMajorVersion, + } + : undefined, + parameterGroupFamily: props.version ? `${props.engineType}-${props.version.sqlServerMajorVersion}` : undefined, }); } @@ -286,20 +913,14 @@ abstract class SqlServerInstanceEngine extends InstanceEngineBase { * Properties for SQL Server Standard Edition instance engines. * Used in {@link DatabaseInstanceEngine.sqlServerSe}. */ -export interface SqlServerSeInstanceEngineProps extends InstanceEngineProps { +export interface SqlServerSeInstanceEngineProps extends SqlServerInstanceEngineProps { } -class SqlServerSeInstanceEngine extends SqlServerInstanceEngine { - constructor(props: SqlServerSeInstanceEngineProps = {}) { +class SqlServerSeInstanceEngine extends SqlServerInstanceEngineBase { + constructor(version?: SqlServerEngineVersion) { super({ engineType: 'sqlserver-se', - parameterGroupFamilies: [ - { engineMajorVersion: '11', parameterGroupFamily: 'sqlserver-se-11.0' }, - { engineMajorVersion: '12', parameterGroupFamily: 'sqlserver-se-12.0' }, - { engineMajorVersion: '13', parameterGroupFamily: 'sqlserver-se-13.0' }, - { engineMajorVersion: '14', parameterGroupFamily: 'sqlserver-se-14.0' }, - ], - version: props.version, + version, }); } } @@ -308,20 +929,14 @@ class SqlServerSeInstanceEngine extends SqlServerInstanceEngine { * Properties for SQL Server Express Edition instance engines. * Used in {@link DatabaseInstanceEngine.sqlServerEx}. */ -export interface SqlServerExInstanceEngineProps extends InstanceEngineProps { +export interface SqlServerExInstanceEngineProps extends SqlServerInstanceEngineProps { } -class SqlServerExInstanceEngine extends SqlServerInstanceEngine { - constructor(props: SqlServerExInstanceEngineProps = {}) { +class SqlServerExInstanceEngine extends SqlServerInstanceEngineBase { + constructor(version?: SqlServerEngineVersion) { super({ engineType: 'sqlserver-ex', - parameterGroupFamilies: [ - { engineMajorVersion: '11', parameterGroupFamily: 'sqlserver-ex-11.0' }, - { engineMajorVersion: '12', parameterGroupFamily: 'sqlserver-ex-12.0' }, - { engineMajorVersion: '13', parameterGroupFamily: 'sqlserver-ex-13.0' }, - { engineMajorVersion: '14', parameterGroupFamily: 'sqlserver-ex-14.0' }, - ], - version: props.version, + version, }); } } @@ -330,20 +945,14 @@ class SqlServerExInstanceEngine extends SqlServerInstanceEngine { * Properties for SQL Server Web Edition instance engines. * Used in {@link DatabaseInstanceEngine.sqlServerWeb}. */ -export interface SqlServerWebInstanceEngineProps extends InstanceEngineProps { +export interface SqlServerWebInstanceEngineProps extends SqlServerInstanceEngineProps { } -class SqlServerWebInstanceEngine extends SqlServerInstanceEngine { - constructor(props: SqlServerWebInstanceEngineProps = {}) { +class SqlServerWebInstanceEngine extends SqlServerInstanceEngineBase { + constructor(version?: SqlServerEngineVersion) { super({ engineType: 'sqlserver-web', - parameterGroupFamilies: [ - { engineMajorVersion: '11', parameterGroupFamily: 'sqlserver-web-11.0' }, - { engineMajorVersion: '12', parameterGroupFamily: 'sqlserver-web-12.0' }, - { engineMajorVersion: '13', parameterGroupFamily: 'sqlserver-web-13.0' }, - { engineMajorVersion: '14', parameterGroupFamily: 'sqlserver-web-14.0' }, - ], - version: props.version, + version, }); } } @@ -352,21 +961,14 @@ class SqlServerWebInstanceEngine extends SqlServerInstanceEngine { * Properties for SQL Server Enterprise Edition instance engines. * Used in {@link DatabaseInstanceEngine.sqlServerEe}. */ -export interface SqlServerEeInstanceEngineProps extends InstanceEngineProps { +export interface SqlServerEeInstanceEngineProps extends SqlServerInstanceEngineProps { } -class SqlServerEeInstanceEngine extends SqlServerInstanceEngine { - constructor(props: SqlServerEeInstanceEngineProps = {}) { +class SqlServerEeInstanceEngine extends SqlServerInstanceEngineBase { + constructor(version?: SqlServerEngineVersion) { super({ engineType: 'sqlserver-ee', - parameterGroupFamilies: [ - { engineMajorVersion: '11', parameterGroupFamily: 'sqlserver-ee-11.0' }, - { engineMajorVersion: '12', parameterGroupFamily: 'sqlserver-ee-12.0' }, - { engineMajorVersion: '13', parameterGroupFamily: 'sqlserver-ee-13.0' }, - { engineMajorVersion: '14', parameterGroupFamily: 'sqlserver-ee-14.0' }, - ], - defaultInstanceType: ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.XLARGE), - version: props.version, + version, }); } } @@ -376,80 +978,146 @@ class SqlServerEeInstanceEngine extends SqlServerInstanceEngine { * secret rotation. */ export class DatabaseInstanceEngine { + /** + * The unversioned 'mariadb' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link mariaDb()} method + */ public static readonly MARIADB: IInstanceEngine = new MariaDbInstanceEngine(); + /** + * The unversioned 'mysql' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link mysql()} method + */ public static readonly MYSQL: IInstanceEngine = new MySqlInstanceEngine(); + /** + * The unversioned 'oracle-ee' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link oracleEe()} method + */ public static readonly ORACLE_EE: IInstanceEngine = new OracleEeInstanceEngine(); + /** + * The unversioned 'oracle-se2' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link oracleSe2()} method + */ public static readonly ORACLE_SE2: IInstanceEngine = new OracleSe2InstanceEngine(); + /** + * The unversioned 'oracle-se1' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link oracleSe1()} method + */ public static readonly ORACLE_SE1: IInstanceEngine = new OracleSe1InstanceEngine(); + /** + * The unversioned 'oracle-se' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link oracleSe()} method + */ public static readonly ORACLE_SE: IInstanceEngine = new OracleSeInstanceEngine(); + /** + * The unversioned 'postgres' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link postgres()} method + */ public static readonly POSTGRES: IInstanceEngine = new PostgresInstanceEngine(); + /** + * The unversioned 'sqlserver-ee' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link sqlServerEe()} method + */ public static readonly SQL_SERVER_EE: IInstanceEngine = new SqlServerEeInstanceEngine(); + /** + * The unversioned 'sqlserver-se' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link sqlServerSe()} method + */ public static readonly SQL_SERVER_SE: IInstanceEngine = new SqlServerSeInstanceEngine(); + /** + * The unversioned 'sqlserver-ex' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link sqlServerEx()} method + */ public static readonly SQL_SERVER_EX: IInstanceEngine = new SqlServerExInstanceEngine(); + /** + * The unversioned 'sqlserver-web' instance engine. + * + * @deprecated using unversioned engines is an availability risk. + * We recommend using versioned engines created using the {@link sqlServerWeb()} method + */ public static readonly SQL_SERVER_WEB: IInstanceEngine = new SqlServerWebInstanceEngine(); /** Creates a new MariaDB instance engine. */ public static mariaDb(props: MariaDbInstanceEngineProps): IInstanceEngine { - return new MariaDbInstanceEngine(props); + return new MariaDbInstanceEngine(props.version); } /** Creates a new MySQL instance engine. */ public static mysql(props: MySqlInstanceEngineProps): IInstanceEngine { - return new MySqlInstanceEngine(props); + return new MySqlInstanceEngine(props.version); } /** Creates a new PostgreSQL instance engine. */ public static postgres(props: PostgresInstanceEngineProps): IInstanceEngine { - return new PostgresInstanceEngine(props); + return new PostgresInstanceEngine(props.version); } /** Creates a new Oracle Standard Edition instance engine. */ public static oracleSe(props: OracleSeInstanceEngineProps): IInstanceEngine { - return new OracleSeInstanceEngine(props); + return new OracleSeInstanceEngine(props.version); } /** Creates a new Oracle Standard Edition 1 instance engine. */ public static oracleSe1(props: OracleSe1InstanceEngineProps): IInstanceEngine { - return new OracleSe1InstanceEngine(props); + return new OracleSe1InstanceEngine(props.version); } /** Creates a new Oracle Standard Edition 1 instance engine. */ public static oracleSe2(props: OracleSe2InstanceEngineProps): IInstanceEngine { - return new OracleSe2InstanceEngine(props); + return new OracleSe2InstanceEngine(props.version); } /** Creates a new Oracle Enterprise Edition instance engine. */ public static oracleEe(props: OracleEeInstanceEngineProps): IInstanceEngine { - return new OracleEeInstanceEngine(props); + return new OracleEeInstanceEngine(props.version); } /** Creates a new SQL Server Standard Edition instance engine. */ public static sqlServerSe(props: SqlServerSeInstanceEngineProps): IInstanceEngine { - return new SqlServerSeInstanceEngine(props); + return new SqlServerSeInstanceEngine(props.version); } /** Creates a new SQL Server Express Edition instance engine. */ public static sqlServerEx(props: SqlServerExInstanceEngineProps): IInstanceEngine { - return new SqlServerExInstanceEngine(props); + return new SqlServerExInstanceEngine(props.version); } /** Creates a new SQL Server Web Edition instance engine. */ public static sqlServerWeb(props: SqlServerWebInstanceEngineProps): IInstanceEngine { - return new SqlServerWebInstanceEngine(props); + return new SqlServerWebInstanceEngine(props.version); } /** Creates a new SQL Server Enterprise Edition instance engine. */ public static sqlServerEe(props: SqlServerEeInstanceEngineProps): IInstanceEngine { - return new SqlServerEeInstanceEngine(props); + return new SqlServerEeInstanceEngine(props.version); } } diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index c43c2ab395a0d..0890b26b705d2 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -686,7 +686,7 @@ abstract class DatabaseInstanceSource extends DatabaseInstanceNew implements IDa dbName: props.databaseName, dbParameterGroupName: instanceParameterGroupConfig?.parameterGroupName, engine: props.engine.engineType, - engineVersion: props.engine.engineVersion, + engineVersion: props.engine.engineVersion?.fullVersion, licenseModel: props.licenseModel, timezone: props.timezone, }; diff --git a/packages/@aws-cdk/aws-rds/lib/option-group.ts b/packages/@aws-cdk/aws-rds/lib/option-group.ts index a12b5bb44b13e..418c71d1c7c6e 100644 --- a/packages/@aws-cdk/aws-rds/lib/option-group.ts +++ b/packages/@aws-cdk/aws-rds/lib/option-group.ts @@ -104,10 +104,9 @@ export class OptionGroup extends Resource implements IOptionGroup { constructor(scope: Construct, id: string, props: OptionGroupProps) { super(scope, id); - const majorEngineVersion = props.engine.engineVersion; + const majorEngineVersion = props.engine.engineVersion?.majorVersion; if (!majorEngineVersion) { - throw new Error('OptionGroup can only be used with an engine that has a specific version. ' + - `Use the withVersion method to specify the version for engine ${props.engine.engineType}`); + throw new Error("OptionGroup cannot be used with an engine that doesn't specify a version"); } const optionGroup = new CfnOptionGroup(this, 'Resource', { engineName: props.engine.engineType, diff --git a/packages/@aws-cdk/aws-rds/lib/parameter-group.ts b/packages/@aws-cdk/aws-rds/lib/parameter-group.ts index 0c5ead62727c3..bdd4c05525889 100644 --- a/packages/@aws-cdk/aws-rds/lib/parameter-group.ts +++ b/packages/@aws-cdk/aws-rds/lib/parameter-group.ts @@ -123,7 +123,11 @@ export class ParameterGroup extends Resource implements IParameterGroup { constructor(scope: Construct, id: string, props: ParameterGroupProps) { super(scope, id); - this.family = props.engine.parameterGroupFamily; + const family = props.engine.parameterGroupFamily; + if (!family) { + throw new Error("ParameterGroup cannot be used with an engine that doesn't specify a version"); + } + this.family = family; this.description = props.description; this.parameters = props.parameters ?? {}; } diff --git a/packages/@aws-cdk/aws-rds/lib/private/parameter-group-family-mapping.ts b/packages/@aws-cdk/aws-rds/lib/private/parameter-group-family-mapping.ts deleted file mode 100644 index 98e83f9536206..0000000000000 --- a/packages/@aws-cdk/aws-rds/lib/private/parameter-group-family-mapping.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { compare } from './version'; - -/** - * Engine major version and parameter group family pairs. - */ -export interface ParameterGroupFamilyMapping { - /** - * The engine major version name - */ - readonly engineMajorVersion: string; - - /** - * The parameter group family name - */ - readonly parameterGroupFamily: string -} - -/** - * Get the latest parameter group family for this engine. Latest is determined using semver on the engine major version. - * When `engineVersion` is specified, return the parameter group family corresponding to that engine version. - * Return undefined if no parameter group family is defined for this engine or for the requested `engineVersion`. - */ -export function calculateParameterGroupFamily( - parameterGroupFamilies: ParameterGroupFamilyMapping[] | undefined, - engineVersion: string | undefined): string | undefined { - if (parameterGroupFamilies === undefined) { - return undefined; - } - if (engineVersion !== undefined) { - const family = parameterGroupFamilies.find(x => engineVersion.startsWith(x.engineMajorVersion)); - if (family) { - return family.parameterGroupFamily; - } - } else if (parameterGroupFamilies.length > 0) { - const sorted = parameterGroupFamilies.slice().sort((a, b) => { - return compare(a.engineMajorVersion, b.engineMajorVersion); - }).reverse(); - return sorted[0].parameterGroupFamily; - } - return undefined; -} diff --git a/packages/@aws-cdk/aws-rds/lib/private/version.ts b/packages/@aws-cdk/aws-rds/lib/private/version.ts deleted file mode 100644 index 9e7ce227c2b5c..0000000000000 --- a/packages/@aws-cdk/aws-rds/lib/private/version.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Compare two version strings. Fails if the comparison has to tiebreak with non-numbers. - * @returns 0 if both are same, 1 if 'a' is later version than 'b' and -1 if 'b' is later version than 'a' - */ -export function compare(a: string, b: string) { - const aParts = a.split('.'); - const bParts = b.split('.'); - for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) { - if (i === aParts.length) { return -1; } - if (i === bParts.length) { return 1; } - - if (!aParts[i] || !bParts[i] || isNaN(aParts[i] as any) || isNaN(bParts[i] as any)) { - throw new Error(`Can only compare version strings with numbers. Received [${a}] and [${b}].`); - } - const partCompare = parseInt(aParts[i], 10) - parseInt(bParts[i], 10); - - if (partCompare < 0) { return -1; } - if (partCompare > 0) { return 1; } - } - return 0; -} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/package.json b/packages/@aws-cdk/aws-rds/package.json index dd3795b7497cc..d28f9f3337839 100644 --- a/packages/@aws-cdk/aws-rds/package.json +++ b/packages/@aws-cdk/aws-rds/package.json @@ -110,7 +110,6 @@ "props-physical-name:@aws-cdk/aws-rds.DatabaseInstanceReadReplicaProps", "props-physical-name:@aws-cdk/aws-rds.DatabaseSecretProps", "props-physical-name:@aws-cdk/aws-rds.OptionGroupProps", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.ORACLE_SE2", "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.semanticVersion", "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.applicationId", "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.SQLSERVER_ROTATION_SINGLE_USER", @@ -122,20 +121,7 @@ "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.MYSQL_ROTATION_SINGLE_USER", "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.MYSQL_ROTATION_MULTI_USER", "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.MARIADB_ROTATION_SINGLE_USER", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseClusterEngine.AURORA", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseClusterEngine.AURORA_MYSQL", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseClusterEngine.AURORA_POSTGRESQL", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.MARIADB", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.MYSQL", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.ORACLE_EE", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.ORACLE_SE", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.ORACLE_SE1", - "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.MARIADB_ROTATION_MULTI_USER", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.POSTGRES", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.SQL_SERVER_EE", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.SQL_SERVER_EX", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.SQL_SERVER_SE", - "docs-public-apis:@aws-cdk/aws-rds.DatabaseInstanceEngine.SQL_SERVER_WEB" + "docs-public-apis:@aws-cdk/aws-rds.SecretRotationApplication.MARIADB_ROTATION_MULTI_USER" ] }, "stability": "experimental", diff --git a/packages/@aws-cdk/aws-rds/test/integ.instance.lit.ts b/packages/@aws-cdk/aws-rds/test/integ.instance.lit.ts index 405d1d1be69cb..f98c65a0950f3 100644 --- a/packages/@aws-cdk/aws-rds/test/integ.instance.lit.ts +++ b/packages/@aws-cdk/aws-rds/test/integ.instance.lit.ts @@ -18,9 +18,7 @@ class DatabaseInstanceStack extends cdk.Stack { /// !show // Set open cursors with parameter group const parameterGroup = new rds.ParameterGroup(this, 'ParameterGroup', { - engine: rds.DatabaseInstanceEngine.oracleSe1({ - version: '11.2', - }), + engine: rds.DatabaseInstanceEngine.ORACLE_SE1, parameters: { open_cursors: '2500', }, @@ -28,9 +26,7 @@ class DatabaseInstanceStack extends cdk.Stack { /// Add XMLDB and OEM with option group const optionGroup = new rds.OptionGroup(this, 'OptionGroup', { - engine: rds.DatabaseInstanceEngine.oracleSe1({ - version: '11.2', - }), + engine: rds.DatabaseInstanceEngine.ORACLE_SE1, configurations: [ { name: 'XMLDB', diff --git a/packages/@aws-cdk/aws-rds/test/private/test.version.ts b/packages/@aws-cdk/aws-rds/test/private/test.version.ts deleted file mode 100644 index 2977d702bd5cb..0000000000000 --- a/packages/@aws-cdk/aws-rds/test/private/test.version.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Test } from 'nodeunit'; -import { compare } from '../../lib/private/version'; - -export = { - 'compare - same versions'(test: Test) { - test.equals(compare('1', '1'), 0); - test.equals(compare('1.0', '1.0'), 0); - test.done(); - }, - - 'compare - a < b'(test: Test) { - test.equals(compare('1', '2'), -1); - test.equals(compare('1.0', '1.2'), -1); - test.equals(compare('1.3', '4'), -1); - test.equals(compare('1', '1.2'), -1); - test.equals(compare('1.0', '2.0'), -1); - test.equals(compare('4', '10'), -1); - test.done(); - }, - - 'compare - a > b'(test: Test) { - test.equals(compare('2', '1'), 1); - test.equals(compare('1.2', '1.0'), 1); - test.equals(compare('1.2', '1'), 1); - test.equals(compare('4', '1.2'), 1); - test.equals(compare('2.0', '1.0'), 1); - test.equals(compare('10', '4'), 1); - test.done(); - }, - - 'compare - NaN'(test: Test) { - test.throws(() => compare('1', ''), /only compare version strings with numbers/); - test.throws(() => compare('', '1'), /only compare version strings with numbers/); - test.throws(() => compare('', ''), /only compare version strings with numbers/); - test.throws(() => compare('4x', '1.0'), /only compare version strings with numbers/); - test.done(); - }, -}; \ No newline at end of file diff --git a/packages/@aws-cdk/aws-rds/test/test.cluster-engine.ts b/packages/@aws-cdk/aws-rds/test/test.cluster-engine.ts index f33cf5404fb25..e32db06a40f9b 100644 --- a/packages/@aws-cdk/aws-rds/test/test.cluster-engine.ts +++ b/packages/@aws-cdk/aws-rds/test/test.cluster-engine.ts @@ -1,8 +1,8 @@ import { Test } from 'nodeunit'; -import { DatabaseClusterEngine } from '../lib'; +import { AuroraEngineVersion, AuroraMysqlEngineVersion, AuroraPostgresEngineVersion, DatabaseClusterEngine } from '../lib'; export = { - 'cluster parameter group correctly determined for AURORA'(test: Test) { + "default parameterGroupFamily for versionless Aurora cluster engine is 'aurora5.6'"(test: Test) { // GIVEN const engine = DatabaseClusterEngine.AURORA; @@ -15,7 +15,7 @@ export = { test.done(); }, - 'cluster parameter group correctly determined for AURORA_MYSQL'(test: Test) { + "default parameterGroupFamily for versionless Aurora MySQL cluster engine is 'aurora-mysql5.7'"(test: Test) { // GIVEN const engine = DatabaseClusterEngine.AURORA_MYSQL; @@ -28,7 +28,7 @@ export = { test.done(); }, - 'cluster parameter group correctly determined for AURORA_POSTGRESQL'(test: Test) { + 'default parameterGroupFamily for versionless Aurora PostgreSQL is not defined'(test: Test) { // GIVEN const engine = DatabaseClusterEngine.AURORA_POSTGRESQL; @@ -36,7 +36,7 @@ export = { const family = engine.parameterGroupFamily; // THEN - test.equals(family, 'aurora-postgresql11'); + test.equals(family, undefined); test.done(); }, @@ -44,7 +44,7 @@ export = { 'cluster parameter group correctly determined for AURORA and given version'(test: Test) { // GIVEN const engine = DatabaseClusterEngine.aurora({ - version: '5.6.mysql_aurora.1.22.2', + version: AuroraEngineVersion.VER_1_22_2, }); // WHEN @@ -59,7 +59,7 @@ export = { 'cluster parameter group correctly determined for AURORA_MYSQL and given version'(test: Test) { // GIVEN const engine = DatabaseClusterEngine.auroraMysql({ - version: '5.7.mysql_aurora.2.07.1', + version: AuroraMysqlEngineVersion.VER_2_07_1, }); // WHEN @@ -74,7 +74,7 @@ export = { 'cluster parameter group correctly determined for AURORA_POSTGRESQL and given version'(test: Test) { // GIVEN const engine = DatabaseClusterEngine.auroraPostgres({ - version: '11.6', + version: AuroraPostgresEngineVersion.VER_11_6, }); // WHEN @@ -89,23 +89,20 @@ export = { 'parameter group family'(test: Test) { // the PostgreSQL engine knows about the following major versions: 9.6, 10 and 11 - test.throws(() => { - DatabaseClusterEngine.auroraPostgres({ version: '8' }); - }, /No parameter group family found for database engine aurora-postgresql with version 8/); + test.equals(DatabaseClusterEngine.auroraPostgres({ version: AuroraPostgresEngineVersion.of('8', '8') }).parameterGroupFamily, + 'aurora-postgresql8'); - test.throws(() => { - DatabaseClusterEngine.auroraPostgres({ version: '9' }); - }, /No parameter group family found for database engine aurora-postgresql with version 9/); + test.equals(DatabaseClusterEngine.auroraPostgres({ version: AuroraPostgresEngineVersion.of('9', '9') }).parameterGroupFamily, + 'aurora-postgresql9'); - test.throws(() => { - DatabaseClusterEngine.auroraPostgres({ version: '9.7' }); - }, /No parameter group family found for database engine aurora-postgresql with version 9\.7/); + test.equals(DatabaseClusterEngine.auroraPostgres({ version: AuroraPostgresEngineVersion.of('9.7', '9.7') }).parameterGroupFamily, + 'aurora-postgresql9.7'); - test.equals(DatabaseClusterEngine.auroraPostgres({ version: '9.6' }).parameterGroupFamily, + test.equals(DatabaseClusterEngine.auroraPostgres({ version: AuroraPostgresEngineVersion.of('9.6', '9.6') }).parameterGroupFamily, 'aurora-postgresql9.6'); - test.equals(DatabaseClusterEngine.auroraPostgres({ version: '9.6.1' }).parameterGroupFamily, + test.equals(DatabaseClusterEngine.auroraPostgres({ version: AuroraPostgresEngineVersion.of('9.6.1', '9.6') }).parameterGroupFamily, 'aurora-postgresql9.6'); - test.equals(DatabaseClusterEngine.auroraPostgres({ version: '10.0' }).parameterGroupFamily, + test.equals(DatabaseClusterEngine.auroraPostgres({ version: AuroraPostgresEngineVersion.of('10.0', '10') }).parameterGroupFamily, 'aurora-postgresql10'); test.done(); diff --git a/packages/@aws-cdk/aws-rds/test/test.cluster.ts b/packages/@aws-cdk/aws-rds/test/test.cluster.ts index e9b5015e0ba0f..85d2a6d2b75d4 100644 --- a/packages/@aws-cdk/aws-rds/test/test.cluster.ts +++ b/packages/@aws-cdk/aws-rds/test/test.cluster.ts @@ -5,7 +5,7 @@ import * as kms from '@aws-cdk/aws-kms'; import * as s3 from '@aws-cdk/aws-s3'; import * as cdk from '@aws-cdk/core'; import { Test } from 'nodeunit'; -import { DatabaseCluster, DatabaseClusterEngine, ParameterGroup } from '../lib'; +import { AuroraMysqlEngineVersion, AuroraPostgresEngineVersion, DatabaseCluster, DatabaseClusterEngine, ParameterGroup } from '../lib'; export = { 'creating a Cluster also creates 2 DB Instances'(test: Test) { @@ -300,7 +300,7 @@ export = { // WHEN new DatabaseCluster(stack, 'Database', { engine: DatabaseClusterEngine.auroraMysql({ - version: '5.7.mysql_aurora.2.04.4', + version: AuroraMysqlEngineVersion.VER_2_04_4, }), masterUser: { username: 'admin', @@ -328,7 +328,7 @@ export = { // WHEN new DatabaseCluster(stack, 'Database', { engine: DatabaseClusterEngine.auroraPostgres({ - version: '10.7', + version: AuroraPostgresEngineVersion.VER_10_7, }), masterUser: { username: 'admin', @@ -965,7 +965,9 @@ export = { // WHEN new DatabaseCluster(stack, 'Database', { - engine: DatabaseClusterEngine.AURORA_POSTGRESQL, + engine: DatabaseClusterEngine.auroraPostgres({ + version: AuroraPostgresEngineVersion.VER_11_4, + }), instances: 1, masterUser: { username: 'admin', diff --git a/packages/@aws-cdk/aws-rds/test/test.instance-engine.ts b/packages/@aws-cdk/aws-rds/test/test.instance-engine.ts new file mode 100644 index 0000000000000..4668cfd683163 --- /dev/null +++ b/packages/@aws-cdk/aws-rds/test/test.instance-engine.ts @@ -0,0 +1,114 @@ +import { Test } from 'nodeunit'; +import * as rds from '../lib'; + +export = { + 'default parameterGroupFamily for versionless MariaDB instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.MARIADB; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + 'default parameterGroupFamily for versionless MySQL instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.MYSQL; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + 'default parameterGroupFamily for versionless PostgreSQL instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.POSTGRES; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + "default parameterGroupFamily for versionless Oracle SE instance engine is 'oracle-se-11.2'"(test: Test) { + const engine = rds.DatabaseInstanceEngine.ORACLE_SE; + + const family = engine.parameterGroupFamily; + + test.equals(family, 'oracle-se-11.2'); + + test.done(); + }, + + "default parameterGroupFamily for versionless Oracle SE 1 instance engine is 'oracle-se1-11.2'"(test: Test) { + const engine = rds.DatabaseInstanceEngine.ORACLE_SE1; + + const family = engine.parameterGroupFamily; + + test.equals(family, 'oracle-se1-11.2'); + + test.done(); + }, + + 'default parameterGroupFamily for versionless Oracle SE 2 instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.ORACLE_SE2; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + 'default parameterGroupFamily for versionless Oracle EE instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.ORACLE_EE; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + 'default parameterGroupFamily for versionless SQL Server SE instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.SQL_SERVER_SE; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + 'default parameterGroupFamily for versionless SQL Server EX instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.SQL_SERVER_EX; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + 'default parameterGroupFamily for versionless SQL Server Web instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.SQL_SERVER_WEB; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, + + 'default parameterGroupFamily for versionless SQL Server EE instance engine is not defined'(test: Test) { + const engine = rds.DatabaseInstanceEngine.SQL_SERVER_EE; + + const family = engine.parameterGroupFamily; + + test.equals(family, undefined); + + test.done(); + }, +}; diff --git a/packages/@aws-cdk/aws-rds/test/test.instance.ts b/packages/@aws-cdk/aws-rds/test/test.instance.ts index 40b5caa91dca8..39136b7bc45a6 100644 --- a/packages/@aws-cdk/aws-rds/test/test.instance.ts +++ b/packages/@aws-cdk/aws-rds/test/test.instance.ts @@ -195,9 +195,7 @@ export = { const vpc = new ec2.Vpc(stack, 'VPC'); const optionGroup = new rds.OptionGroup(stack, 'OptionGroup', { - engine: rds.DatabaseInstanceEngine.oracleSe1({ - version: '11.2', - }), + engine: rds.DatabaseInstanceEngine.ORACLE_SE1, configurations: [ { name: 'XMLDB', @@ -206,7 +204,9 @@ export = { }); const parameterGroup = new rds.ParameterGroup(stack, 'ParameterGroup', { - engine: rds.DatabaseInstanceEngine.SQL_SERVER_EE, + engine: rds.DatabaseInstanceEngine.sqlServerEe({ + version: rds.SqlServerEngineVersion.VER_11, + }), description: 'desc', parameters: { key: 'value', diff --git a/packages/@aws-cdk/aws-rds/test/test.option-group.ts b/packages/@aws-cdk/aws-rds/test/test.option-group.ts index 0a7a57099d462..6152f45e881cd 100644 --- a/packages/@aws-cdk/aws-rds/test/test.option-group.ts +++ b/packages/@aws-cdk/aws-rds/test/test.option-group.ts @@ -2,7 +2,7 @@ import { expect, haveResource } from '@aws-cdk/assert'; import * as ec2 from '@aws-cdk/aws-ec2'; import * as cdk from '@aws-cdk/core'; import { Test } from 'nodeunit'; -import { DatabaseInstanceEngine, OptionGroup } from '../lib'; +import { DatabaseInstanceEngine, OptionGroup, OracleEngineVersion, OracleLegacyEngineVersion } from '../lib'; export = { 'create an option group'(test: Test) { @@ -12,7 +12,7 @@ export = { // WHEN new OptionGroup(stack, 'Options', { engine: DatabaseInstanceEngine.oracleSe1({ - version: '11.2', + version: OracleLegacyEngineVersion.VER_11_2, }), configurations: [ { @@ -44,7 +44,7 @@ export = { // WHEN const optionGroup = new OptionGroup(stack, 'Options', { engine: DatabaseInstanceEngine.oracleSe({ - version: '11.2', + version: OracleLegacyEngineVersion.VER_11_2, }), configurations: [ { @@ -103,7 +103,7 @@ export = { // THEN test.throws(() => new OptionGroup(stack, 'Options', { engine: DatabaseInstanceEngine.oracleSe2({ - version: '11.2', + version: OracleEngineVersion.VER_12_1, }), configurations: [ { diff --git a/packages/@aws-cdk/aws-rds/test/test.proxy.ts b/packages/@aws-cdk/aws-rds/test/test.proxy.ts index 3473527054d06..6e4de63c7aeff 100644 --- a/packages/@aws-cdk/aws-rds/test/test.proxy.ts +++ b/packages/@aws-cdk/aws-rds/test/test.proxy.ts @@ -80,7 +80,7 @@ export = { const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new rds.DatabaseCluster(stack, 'Database', { engine: rds.DatabaseClusterEngine.auroraPostgres({ - version: '10.7', + version: rds.AuroraPostgresEngineVersion.VER_10_7, }), masterUser: { username: 'admin', @@ -155,7 +155,7 @@ export = { const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new rds.DatabaseCluster(stack, 'Database', { engine: rds.DatabaseClusterEngine.auroraPostgres({ - version: '10.7', + version: rds.AuroraPostgresEngineVersion.VER_10_7, }), masterUser: { username: 'admin', @@ -187,7 +187,7 @@ export = { const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new rds.DatabaseCluster(stack, 'Database', { - engine: rds.DatabaseClusterEngine.auroraPostgres({ version: '10.7' }), + engine: rds.DatabaseClusterEngine.auroraPostgres({ version: rds.AuroraPostgresEngineVersion.VER_10_7 }), masterUser: { username: 'admin' }, instanceProps: { instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),