-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
integ.cluster.ts
55 lines (45 loc) · 1.59 KB
/
integ.cluster.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as ec2 from '@aws-cdk/aws-ec2';
import * as kms from '@aws-cdk/aws-kms';
import * as cdk from '@aws-cdk/core';
import * as constructs from 'constructs';
import { DatabaseCluster, ClusterParameterGroup } from '../lib';
/*
* Stack verification steps:
* * aws docdb describe-db-clusters --db-cluster-identifier <deployed db cluster identifier>
*/
class TestStack extends cdk.Stack {
constructor(scope: constructs.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 2 });
const params = new ClusterParameterGroup(this, 'Params', {
family: 'docdb3.6',
description: 'A nice parameter group',
parameters: {
audit_logs: 'disabled',
tls: 'enabled',
ttl_monitor: 'enabled',
},
});
const kmsKey = new kms.Key(this, 'DbSecurity', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
const cluster = new DatabaseCluster(this, 'Database', {
engineVersion: '3.6.0',
masterUser: {
username: 'docdb',
password: cdk.SecretValue.unsafePlainText('7959866cacc02c2d243ecfe177464fe6'),
},
instanceType: ec2.InstanceType.of(ec2.InstanceClass.R5, ec2.InstanceSize.LARGE),
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
vpc,
parameterGroup: params,
kmsKey,
removalPolicy: cdk.RemovalPolicy.DESTROY,
enablePerformanceInsights: true,
});
cluster.connections.allowDefaultPortFromAnyIpv4('Open to the world');
}
}
const app = new cdk.App();
new TestStack(app, 'aws-cdk-docdb-integ');
app.synth();