Skip to content

Commit

Permalink
chore: enable logging for DocDB example
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlove-aws committed Aug 6, 2020
1 parent 2a23ae7 commit 70d30ca
Show file tree
Hide file tree
Showing 3 changed files with 15,960 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/kitchen-sink/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import {
DatabaseCluster,
ClusterParameterGroup,
CfnDBCluster,
} from '@aws-cdk/aws-docdb';
import {
AmazonLinuxImage,
Expand Down Expand Up @@ -121,6 +123,23 @@ export class KitchenSinkApp extends App {
filesystem: fileSystem,
});

/**
* This option is part of enabling audit logging for DocumentDB; the other required part is the enabling of the CloudWatch exports below.
*
* Audit logs are a security best-practice. They record connection, data definition language (DDL), user management,
* and authorization events within the database, and are useful for post-incident auditing. That is, they can help you
* figure out what an unauthorized user, who gained access to your database, has done with that access.
*
* For more information about audit logging in DocumentDB, see: https://docs.aws.amazon.com/documentdb/latest/developerguide/event-auditing.html
*/
const parameterGroup = new ClusterParameterGroup(infrastructureStack, 'ParameterGroup', {
description: 'docdb cluster parameter group',
family: 'docdb3.6',
parameters: {
audit_logs: 'enabled',
},
});

/*
* DocumentDB database cluster for storing the render farm database.
*/
Expand All @@ -134,6 +153,7 @@ export class KitchenSinkApp extends App {
InstanceClass.R4,
InstanceSize.LARGE
),
parameterGroup,
vpc,
vpcSubnets: {
onePerAz: true,
Expand All @@ -148,6 +168,13 @@ export class KitchenSinkApp extends App {
removalPolicy: RemovalPolicy.DESTROY
});

/**
* This option enable export audit logs to Amazon CloudWatch.
* This is second options that required for enable audit log.
*/
const cfnDB = database.node.findChild('Resource') as CfnDBCluster;
cfnDB.enableCloudwatchLogsExports = ['audit'];

/**
* Bastion instance.
*
Expand Down
Loading

0 comments on commit 70d30ca

Please sign in to comment.