Skip to content

Commit

Permalink
feat(rds): Implement setting parameter group name
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceWarne committed Apr 25, 2024
1 parent 536d8ff commit dc040be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit dc040be

Please sign in to comment.