-
Notifications
You must be signed in to change notification settings - Fork 0
/
docdb.ts
33 lines (28 loc) · 1.11 KB
/
docdb.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Construct } from "constructs";
import { NestedStack, NestedStackProps, RemovalPolicy } from "aws-cdk-lib";
import { DatabaseCluster } from "aws-cdk-lib/aws-docdb";
import { Instance, InstanceClass, InstanceSize, InstanceType, SecurityGroup, SubnetType, Vpc } from "aws-cdk-lib/aws-ec2";
import * as Config from "../config.json"
interface DocDBStackProps extends NestedStackProps {
vpc: Vpc
docDBSecGrp: SecurityGroup
}
export class DocDB extends NestedStack {
docdbcluster: DatabaseCluster
constructor(scope: Construct, id: string, props: DocDBStackProps) {
super(scope, id, props)
this.docdbcluster = new DatabaseCluster(this, 'DocDB', {
masterUser: {
username: Config.DocDB.dbUserName
},
instances: 1,
instanceType: InstanceType.of(InstanceClass.R5, InstanceSize.LARGE),
vpc: props.vpc,
vpcSubnets: {
subnetType: SubnetType.PRIVATE_ISOLATED
},
securityGroup: props.docDBSecGrp
})
this.docdbcluster.applyRemovalPolicy(RemovalPolicy.DESTROY)
}
}