Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rds): implement setting parameter group name #29965

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -394,8 +394,9 @@
"ParameterGroup5E32DECB": {
"Type": "AWS::RDS::DBParameterGroup",
"Properties": {
"DBParameterGroupName": "name",
"Description": "desc",
"Family": "postgres15",
"Family": "postgres16",
"Parameters": {}
},
"UpdateReplacePolicy": "Delete",
Expand Down Expand Up @@ -481,7 +482,7 @@
},
"EnableIAMDatabaseAuthentication": true,
"Engine": "postgres",
"EngineVersion": "15.2",
"EngineVersion": "16.2",
"MasterUserPassword": {
"Fn::Join": [
"",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -11,13 +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_15_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
description: 'desc',
removalPolicy: cdk.RemovalPolicy.DESTROY,
name: 'name',
});

new rds.DatabaseInstance(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_15_2 }),
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_16_2 }),
vpc,
multiAz: false,
publiclyAccessible: true,
Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-rds/README.md
Expand Up @@ -1078,6 +1078,7 @@ const parameterGroup = new rds.ParameterGroup(this, 'ParameterGroup', {
engine: rds.DatabaseInstanceEngine.sqlServerEe({
version: rds.SqlServerEngineVersion.VER_11,
}),
name: 'my-parameter-group',
parameters: {
locks: '100',
},
Expand Down
11 changes: 11 additions & 0 deletions packages/aws-cdk-lib/aws-rds/lib/parameter-group.ts
Expand Up @@ -70,6 +70,13 @@ export interface ParameterGroupProps {
*/
readonly engine: IEngine;

/**
* The name of this parameter group.
*
* @default - CloudFormation-generated name
*/
readonly name?: string;

/**
* Description for this parameter group
*
Expand Down Expand Up @@ -126,6 +133,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
private readonly family: string;
private readonly removalPolicy?: RemovalPolicy;
private readonly description?: string;
private readonly name?: string;

private clusterCfnGroup?: CfnDBClusterParameterGroup;
private instanceCfnGroup?: CfnDBParameterGroup;
Expand All @@ -139,6 +147,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
}
this.family = family;
this.description = props.description;
this.name = props.name;
this.parameters = props.parameters ?? {};
this.removalPolicy = props.removalPolicy;
}
Expand All @@ -149,6 +158,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
this.clusterCfnGroup = new CfnDBClusterParameterGroup(this, id, {
description: this.description || `Cluster parameter group for ${this.family}`,
family: this.family,
dbClusterParameterGroupName: this.name,
parameters: Lazy.any({ produce: () => this.parameters }),
});
}
Expand All @@ -166,6 +176,7 @@ export class ParameterGroup extends Resource implements IParameterGroup {
this.instanceCfnGroup = new CfnDBParameterGroup(this, id, {
description: this.description || `Parameter group for ${this.family}`,
family: this.family,
dbParameterGroupName: this.name,
parameters: Lazy.any({ produce: () => this.parameters }),
});
}
Expand Down
4 changes: 4 additions & 0 deletions packages/aws-cdk-lib/aws-rds/test/parameter-group.test.ts
Expand Up @@ -29,6 +29,7 @@ describe('parameter group', () => {
const parameterGroup = new ParameterGroup(stack, 'Params', {
engine: DatabaseClusterEngine.AURORA,
description: 'desc',
name: 'name',
parameters: {
key: 'value',
},
Expand All @@ -37,6 +38,7 @@ describe('parameter group', () => {

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBParameterGroup', {
DBParameterGroupName: 'name',
Description: 'desc',
Family: 'aurora5.6',
Parameters: {
Expand All @@ -53,6 +55,7 @@ describe('parameter group', () => {
const parameterGroup = new ParameterGroup(stack, 'Params', {
engine: DatabaseClusterEngine.AURORA,
description: 'desc',
name: 'name',
parameters: {
key: 'value',
},
Expand All @@ -61,6 +64,7 @@ describe('parameter group', () => {

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
DBClusterParameterGroupName: 'name',
Description: 'desc',
Family: 'aurora5.6',
Parameters: {
Expand Down