Skip to content

Commit

Permalink
chore(rds): add support for postgres 16.3 engine
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcummings12 committed May 16, 2024
1 parent 7624c62 commit 9f2d669
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ vpc.isolatedSubnets.forEach((subnet, idx) => {
});

new rds.DatabaseInstance(stack, 'DualstackInstance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
credentials: rds.Credentials.fromUsername('postgres', { password: cdk.SecretValue.unsafePlainText('7959866cacc02c2d243ecfe177464fe6') }),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MICRO),
vpc,
Expand All @@ -27,7 +27,7 @@ new rds.DatabaseInstance(stack, 'DualstackInstance', {
});

new rds.DatabaseInstance(stack, 'Ipv4Instance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
credentials: rds.Credentials.fromUsername('postgres', { password: cdk.SecretValue.unsafePlainText('7959866cacc02c2d243ecfe177464fe6') }),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MICRO),
vpc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-rds-instance-s3-postgres-integ');

new rds.DatabaseInstance(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc: new ec2.Vpc(stack, 'VPC', { maxAzs: 2, natGateways: 1, restrictDefaultSecurityGroup: false }),
multiAz: false,
publiclyAccessible: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-rds-instance-with-metric', {
const vpc = new ec2.Vpc(stack, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false });

const instance = new rds.DatabaseInstance(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
multiAz: false,
publiclyAccessible: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const stack = new cdk.Stack(app, 'aws-cdk-rds-instance-with-rds-parameter-group'
const vpc = new ec2.Vpc(stack, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false });

const parameterGroup = new rds.ParameterGroup(stack, 'ParameterGroup', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
description: 'desc',
removalPolicy: cdk.RemovalPolicy.DESTROY,
name: 'name',
});

new rds.DatabaseInstance(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
multiAz: false,
publiclyAccessible: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const kmsKey = new kms.Key(stack, 'SecretEncryptionKey');

const dbInstance = new rds.DatabaseInstance(stack, 'dbInstance', {
engine: rds.DatabaseInstanceEngine.postgres({
version: rds.PostgresEngineVersion.VER_16_2,
version: rds.PostgresEngineVersion.VER_16_3,
}),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MEDIUM),
credentials: rds.Credentials.fromUsername('master', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TestStack extends Stack {
const vpcSubnets: SubnetSelection = { subnetType: SubnetType.PRIVATE_ISOLATED };

const postgresSource = new rds.DatabaseInstance(this, 'PostgresSource', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
backupRetention: Duration.days(5),
instanceType,
vpc,
Expand Down
14 changes: 7 additions & 7 deletions packages/aws-cdk-lib/aws-rds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ Example for max storage configuration:
```ts
declare const vpc: ec2.Vpc;
const instance = new rds.DatabaseInstance(this, 'Instance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
// optional, defaults to m5.large
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
vpc,
Expand All @@ -431,7 +431,7 @@ To use dual-stack mode, specify `NetworkType.DUAL` on the `networkType` property
```ts
declare const vpc: ec2.Vpc; // VPC and subnets must have IPv6 CIDR blocks
const instance = new rds.DatabaseInstance(this, 'Instance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
networkType: rds.NetworkType.DUAL,
publiclyAccessible: false,
Expand All @@ -447,7 +447,7 @@ a source database respectively:
declare const vpc: ec2.Vpc;
new rds.DatabaseInstanceFromSnapshot(this, 'Instance', {
snapshotIdentifier: 'my-snapshot',
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
// optional, defaults to m5.large
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.LARGE),
vpc,
Expand Down Expand Up @@ -602,7 +602,7 @@ The following examples use a `DatabaseInstance`, but the same usage is applicabl

```ts
declare const vpc: ec2.Vpc;
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 });
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });
new rds.DatabaseInstance(this, 'InstanceWithUsername', {
engine,
vpc,
Expand All @@ -627,7 +627,7 @@ Secrets generated by `fromGeneratedSecret()` can be customized:

```ts
declare const vpc: ec2.Vpc;
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 });
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });
const myKey = new kms.Key(this, 'MyKey');

new rds.DatabaseInstance(this, 'InstanceWithCustomizedSecret', {
Expand All @@ -648,7 +648,7 @@ As noted above, Databases created with `DatabaseInstanceFromSnapshot` or `Server

```ts
declare const vpc: ec2.Vpc;
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 });
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });
const myKey = new kms.Key(this, 'MyKey');

new rds.DatabaseInstanceFromSnapshot(this, 'InstanceFromSnapshotWithCustomizedSecret', {
Expand Down Expand Up @@ -1024,7 +1024,7 @@ const auditLogGroup = cluster.cloudwatchLogGroups.audit;
// Exporting logs from an instance
const instance = new rds.DatabaseInstance(this, 'Instance', {
engine: rds.DatabaseInstanceEngine.postgres({
version: rds.PostgresEngineVersion.VER_16_2,
version: rds.PostgresEngineVersion.VER_16_3,
}),
vpc,
cloudwatchLogsExports: ['postgresql'], // Export the PostgreSQL logs
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/aws-rds/lib/cluster-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,8 @@ export class AuroraPostgresEngineVersion {
public static readonly VER_16_1 = AuroraPostgresEngineVersion.of('16.1', '16', { s3Import: true, s3Export: true });
/** Version "16.2". */
public static readonly VER_16_2 = AuroraPostgresEngineVersion.of('16.2', '16', { s3Import: true, s3Export: true });
/** Version "16.3". */
public static readonly VER_16_3 = AuroraPostgresEngineVersion.of('16.3', '16', { s3Import: true, s3Export: true });

/**
* Create a new AuroraPostgresEngineVersion with an arbitrary version.
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/aws-rds/lib/instance-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,8 @@ export class PostgresEngineVersion {
public static readonly VER_16_1 = PostgresEngineVersion.of('16.1', '16', { s3Import: true, s3Export: true });
/** Version "16.2". */
public static readonly VER_16_2 = PostgresEngineVersion.of('16.2', '16', { s3Import: true, s3Export: true });
/** Version "16.3". */
public static readonly VER_16_3 = PostgresEngineVersion.of('16.3', '16', { s3Import: true, s3Export: true });

/**
* Create a new PostgresEngineVersion with an arbitrary version.
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-rds/test/instance-engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe('instance engine', () => {

describe('PostgreSQL engine bindToInstance', () => {
test('returns s3 import/export feature if the version supports it', () => {
const engineNewerVersion = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 });
const engineNewerVersion = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });

const engineConfig = engineNewerVersion.bindToInstance(new cdk.Stack(), {});
expect(engineConfig.features?.s3Import).toEqual('s3Import');
Expand Down
34 changes: 17 additions & 17 deletions packages/aws-cdk-lib/aws-rds/test/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ describe('instance', () => {
// WHEN
const instance = new rds.DatabaseInstanceFromSnapshot(stack, 'Instance', {
snapshotIdentifier: 'my-snapshot',
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.LARGE),
vpc,
cloudwatchLogsExports: [],
Expand Down Expand Up @@ -446,7 +446,7 @@ describe('instance', () => {
test('create an instance from snapshot', () => {
new rds.DatabaseInstanceFromSnapshot(stack, 'Instance', {
snapshotIdentifier: 'my-snapshot',
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.LARGE),
vpc,
});
Expand Down Expand Up @@ -856,7 +856,7 @@ describe('instance', () => {
test('addRotationSingleUser()', () => {
// GIVEN
const instance = new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
});

Expand All @@ -883,7 +883,7 @@ describe('instance', () => {
test('addRotationMultiUser()', () => {
// GIVEN
const instance = new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
});

Expand Down Expand Up @@ -935,7 +935,7 @@ describe('instance', () => {
// WHEN
// DB in isolated subnet (no internet connectivity)
const instance = new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc: vpcWithIsolated,
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
});
Expand Down Expand Up @@ -997,7 +997,7 @@ describe('instance', () => {
// WHEN
// DB in isolated subnet (no internet connectivity)
const instance = new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc: vpcWithIsolated,
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
});
Expand Down Expand Up @@ -1053,7 +1053,7 @@ describe('instance', () => {
// WHEN
// DB in isolated subnet (no internet connectivity)
const instance = new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc: vpcIsolatedOnly,
vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_ISOLATED },
});
Expand Down Expand Up @@ -1559,7 +1559,7 @@ describe('instance', () => {

test('reuse an existing subnet group', () => {
new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
subnetGroup: rds.SubnetGroup.fromSubnetGroupName(stack, 'SubnetGroup', 'my-subnet-group'),
});
Expand All @@ -1572,7 +1572,7 @@ describe('instance', () => {

test('defaultChild returns the DB Instance', () => {
const instance = new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
});

Expand All @@ -1584,7 +1584,7 @@ describe('instance', () => {
new rds.DatabaseInstance(stack, 'Instance', {
vpc,
engine: rds.DatabaseInstanceEngine.postgres({
version: rds.PostgresEngineVersion.VER_16_2,
version: rds.PostgresEngineVersion.VER_16_3,
}),
});

Expand Down Expand Up @@ -1720,7 +1720,7 @@ describe('instance', () => {
test('fromGeneratedSecret', () => {
// WHEN
new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
credentials: rds.Credentials.fromGeneratedSecret('postgres'),
});
Expand All @@ -1746,7 +1746,7 @@ describe('instance', () => {
test('fromGeneratedSecret with replica regions', () => {
// WHEN
new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
credentials: rds.Credentials.fromGeneratedSecret('postgres', {
replicaRegions: [{ region: 'eu-west-1' }],
Expand All @@ -1766,7 +1766,7 @@ describe('instance', () => {
test('fromPassword', () => {
// WHEN
new rds.DatabaseInstance(stack, 'Database', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
vpc,
credentials: rds.Credentials.fromPassword('postgres', cdk.SecretValue.ssmSecure('/dbPassword', '1')),
});
Expand Down Expand Up @@ -1899,7 +1899,7 @@ describe('instance', () => {
const instanceType = ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL);
const backupRetention = cdk.Duration.days(5);
const source = new rds.DatabaseInstance(stack, 'Source', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 }),
backupRetention,
instanceType,
vpc,
Expand All @@ -1918,7 +1918,7 @@ describe('instance', () => {
test('read replica with allocatedStorage', () => {
// GIVEN
const instanceType = ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL);
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 });
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });
const parameterGroup = new rds.ParameterGroup(stack, 'ParameterGroup', { engine });
const source = new rds.DatabaseInstance(stack, 'Source', {
engine,
Expand All @@ -1944,7 +1944,7 @@ describe('instance', () => {
test('can set parameter group on read replica', () => {
// GIVEN
const instanceType = ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL);
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 });
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });
const parameterGroup = new rds.ParameterGroup(stack, 'ParameterGroup', { engine });
const source = new rds.DatabaseInstance(stack, 'Source', {
engine,
Expand Down Expand Up @@ -2008,7 +2008,7 @@ describe('instance', () => {
test('engine is specified for read replica using domain', () => {
// GIVEN
const instanceType = ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.SMALL);
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 });
const engine = rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_3 });
const source = new rds.DatabaseInstance(stack, 'Source', {
engine,
instanceType,
Expand Down

0 comments on commit 9f2d669

Please sign in to comment.