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 1 commit
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
Expand Up @@ -14,6 +14,7 @@ const parameterGroup = new rds.ParameterGroup(stack, 'ParameterGroup', {
engine: rds.DatabaseInstanceEngine.postgres({ version: rds.PostgresEngineVersion.VER_15_2 }),
description: 'desc',
removalPolicy: cdk.RemovalPolicy.DESTROY,
name: 'name',
});

new rds.DatabaseInstance(stack, 'Instance', {
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @default CloudFormation-generated name
* @default - CloudFormation-generated name

Something I learned recently, if the value immediately after a @default tag is not the actual value but rather a sentence describing the value, you need to separate it with a dash - or else it would think that Cloudformation-generated is the default value.

*/
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