Skip to content

Commit

Permalink
refactor: Remove RDS parameter group code
Browse files Browse the repository at this point in the history
Since aws/aws-cdk#18126, this exact logic is handled by aws-cdk.
  • Loading branch information
akash1810 committed Feb 22, 2022
1 parent 7fd02de commit 77585a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/constructs/rds/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("The GuDatabaseInstance class", () => {

expect(stack).toHaveResource("AWS::RDS::DBInstance", {
DBParameterGroupName: {
Ref: "DatabaseInstanceRDSParameterGroup307734CB",
Ref: "DatabaseInstanceTestingParameterGroup0F38B815",
},
});

Expand Down
20 changes: 3 additions & 17 deletions src/constructs/rds/instance.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { InstanceType } from "@aws-cdk/aws-ec2";
import { DatabaseInstance, ParameterGroup } from "@aws-cdk/aws-rds";
import type { DatabaseInstanceProps, IParameterGroup } from "@aws-cdk/aws-rds";
import { DatabaseInstance } from "@aws-cdk/aws-rds";
import type { DatabaseInstanceProps } from "@aws-cdk/aws-rds";
import { Fn } from "@aws-cdk/core";
import { GuStatefulMigratableConstruct } from "../../utils/mixin";
import { GuAppAwareConstruct } from "../../utils/mixin/app-aware-construct";
import type { GuStack } from "../core";
import { AppIdentity } from "../core/identity";
import type { AppIdentity } from "../core/identity";
import type { GuMigratingResource } from "../core/migrating";

export interface GuDatabaseInstanceProps
extends Omit<DatabaseInstanceProps, "instanceType">,
AppIdentity,
GuMigratingResource {
instanceType: string;
parameters?: Record<string, string>;
}

export class GuDatabaseInstance extends GuStatefulMigratableConstruct(GuAppAwareConstruct(DatabaseInstance)) {
Expand All @@ -23,23 +22,10 @@ export class GuDatabaseInstance extends GuStatefulMigratableConstruct(GuAppAware
// This logic ensures the "db." prefix is removed before applying the CFN
const instanceType = new InstanceType(Fn.join("", Fn.split("db.", props.instanceType)));

let parameterGroup: IParameterGroup | undefined;
if (props.parameterGroup) {
parameterGroup = props.parameterGroup;
} else if (props.parameters) {
parameterGroup = new ParameterGroup(scope, `${id}-RDSParameterGroup`, {
engine: props.engine,
parameters: props.parameters,
});
}

super(scope, id, {
deletionProtection: true,
...props,
instanceType,
...(parameterGroup && { parameterGroup }),
});

parameterGroup && AppIdentity.taggedConstruct(props, parameterGroup);
}
}

0 comments on commit 77585a2

Please sign in to comment.