Skip to content

Commit 50331a1

Browse files
feat(rds): implement setting parameter group name (#29965)
### Reason for this change I'd like to be able to set RDS parameter group names using CDK. ### Description of changes I've added a new field `name` to `ParameterGroupProps` used to populate `dbClusterParameterGroupName` and `dbParameterGroupName` where appropriate - AFAICS this couldn't be done at this level previously? ### Description of how you validated changes I've altered a couple of unit tests and an integration test. However I'm unable to run the integration test as the postgres version in the existing snapshot is deprecated (I believe this needs to be deployed before the new snapshot?) which blocks me from deploying. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent a38707b commit 50331a1

File tree

8 files changed

+28
-9
lines changed

8 files changed

+28
-9
lines changed

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.instance-with-parameter-group.js.snapshot/aws-cdk-rds-instance-with-rds-parameter-group.assets.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.instance-with-parameter-group.js.snapshot/aws-cdk-rds-instance-with-rds-parameter-group.template.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,9 @@
394394
"ParameterGroup5E32DECB": {
395395
"Type": "AWS::RDS::DBParameterGroup",
396396
"Properties": {
397+
"DBParameterGroupName": "name",
397398
"Description": "desc",
398-
"Family": "postgres15",
399+
"Family": "postgres16",
399400
"Parameters": {}
400401
},
401402
"UpdateReplacePolicy": "Delete",
@@ -481,7 +482,7 @@
481482
},
482483
"EnableIAMDatabaseAuthentication": true,
483484
"Engine": "postgres",
484-
"EngineVersion": "15.2",
485+
"EngineVersion": "16.2",
485486
"MasterUserPassword": {
486487
"Fn::Join": [
487488
"",

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.instance-with-parameter-group.js.snapshot/manifest.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.instance-with-parameter-group.js.snapshot/tree.json

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-rds/test/integ.instance-with-parameter-group.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ const stack = new cdk.Stack(app, 'aws-cdk-rds-instance-with-rds-parameter-group'
1111
const vpc = new ec2.Vpc(stack, 'VPC', { maxAzs: 2, restrictDefaultSecurityGroup: false });
1212

1313
const parameterGroup = new rds.ParameterGroup(stack, 'ParameterGroup', {
14-
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_15_2 }),
14+
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
1515
description: 'desc',
1616
removalPolicy: cdk.RemovalPolicy.DESTROY,
17+
name: 'name',
1718
});
1819

1920
new rds.DatabaseInstance(stack, 'Instance', {
20-
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_15_2 }),
21+
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
2122
vpc,
2223
multiAz: false,
2324
publiclyAccessible: true,

Diff for: packages/aws-cdk-lib/aws-rds/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ const parameterGroup = new rds.ParameterGroup(this, 'ParameterGroup', {
10781078
engine: rds.DatabaseInstanceEngine.sqlServerEe({
10791079
version: rds.SqlServerEngineVersion.VER_11,
10801080
}),
1081+
name: 'my-parameter-group',
10811082
parameters: {
10821083
locks: '100',
10831084
},

Diff for: packages/aws-cdk-lib/aws-rds/lib/parameter-group.ts

+11
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ export interface ParameterGroupProps {
7070
*/
7171
readonly engine: IEngine;
7272

73+
/**
74+
* The name of this parameter group.
75+
*
76+
* @default - CloudFormation-generated name
77+
*/
78+
readonly name?: string;
79+
7380
/**
7481
* Description for this parameter group
7582
*
@@ -126,6 +133,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
126133
private readonly family: string;
127134
private readonly removalPolicy?: RemovalPolicy;
128135
private readonly description?: string;
136+
private readonly name?: string;
129137

130138
private clusterCfnGroup?: CfnDBClusterParameterGroup;
131139
private instanceCfnGroup?: CfnDBParameterGroup;
@@ -139,6 +147,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
139147
}
140148
this.family = family;
141149
this.description = props.description;
150+
this.name = props.name;
142151
this.parameters = props.parameters ?? {};
143152
this.removalPolicy = props.removalPolicy;
144153
}
@@ -149,6 +158,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
149158
this.clusterCfnGroup = new CfnDBClusterParameterGroup(this, id, {
150159
description: this.description || `Cluster parameter group for ${this.family}`,
151160
family: this.family,
161+
dbClusterParameterGroupName: this.name,
152162
parameters: Lazy.any({ produce: () => this.parameters }),
153163
});
154164
}
@@ -166,6 +176,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
166176
this.instanceCfnGroup = new CfnDBParameterGroup(this, id, {
167177
description: this.description || `Parameter group for ${this.family}`,
168178
family: this.family,
179+
dbParameterGroupName: this.name,
169180
parameters: Lazy.any({ produce: () => this.parameters }),
170181
});
171182
}

Diff for: packages/aws-cdk-lib/aws-rds/test/parameter-group.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe('parameter group', () => {
2929
const parameterGroup = new ParameterGroup(stack, 'Params', {
3030
engine: DatabaseClusterEngine.AURORA,
3131
description: 'desc',
32+
name: 'name',
3233
parameters: {
3334
key: 'value',
3435
},
@@ -37,6 +38,7 @@ describe('parameter group', () => {
3738

3839
// THEN
3940
Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBParameterGroup', {
41+
DBParameterGroupName: 'name',
4042
Description: 'desc',
4143
Family: 'aurora5.6',
4244
Parameters: {
@@ -53,6 +55,7 @@ describe('parameter group', () => {
5355
const parameterGroup = new ParameterGroup(stack, 'Params', {
5456
engine: DatabaseClusterEngine.AURORA,
5557
description: 'desc',
58+
name: 'name',
5659
parameters: {
5760
key: 'value',
5861
},
@@ -61,6 +64,7 @@ describe('parameter group', () => {
6164

6265
// THEN
6366
Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
67+
DBClusterParameterGroupName: 'name',
6468
Description: 'desc',
6569
Family: 'aurora5.6',
6670
Parameters: {

0 commit comments

Comments
 (0)