Skip to content

Commit 9a09985

Browse files
committed
feat: expose cloudwatch log exports for rds
1 parent dd1c7f0 commit 9a09985

3 files changed

Lines changed: 150 additions & 2 deletions

File tree

API.md

Lines changed: 120 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constructs/aurora-cluster.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as cdk from 'aws-cdk-lib';
2-
import { aws_ec2 as ec2, aws_secretsmanager as sm, aws_rds as rds } from 'aws-cdk-lib';
2+
import { aws_ec2 as ec2, aws_secretsmanager as sm, aws_rds as rds, aws_logs as logs } from 'aws-cdk-lib';
33
import { Construct } from 'constructs';
44
import { IDatabase, INetworking } from '../interfaces';
55

@@ -75,6 +75,18 @@ export interface AuroraClusterProps {
7575
* @default - No parameter is overridden.
7676
*/
7777
readonly parameters?: Record<string, string>;
78+
79+
/**
80+
* The list of log types that need to be enabled for exporting to CloudWatch Logs.
81+
* @default - No log types are enabled.
82+
*/
83+
readonly cloudwatchLogsExports?: string[];
84+
85+
/**
86+
* The number of days log events are kept in CloudWatch Logs. When updating this property, unsetting it doesn't remove the log retention policy. To remove the retention policy, set the value to Infinity.
87+
* @default logs never expire
88+
*/
89+
readonly cloudwatchLogsRetention?: logs.RetentionDays;
7890
}
7991

8092
/**
@@ -153,6 +165,8 @@ export class AuroraCluster extends Construct implements IDatabase {
153165
parameterGroup: this.parameterGroup,
154166
storageEncrypted: true,
155167
securityGroups: [securityGroup],
168+
cloudwatchLogsExports: props.cloudwatchLogsExports,
169+
cloudwatchLogsRetention: props.cloudwatchLogsRetention,
156170
removalPolicy,
157171
backup,
158172
});

src/constructs/database-instance.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as cdk from 'aws-cdk-lib';
2-
import { aws_ec2 as ec2, aws_secretsmanager as sm, aws_rds as rds } from 'aws-cdk-lib';
2+
import { aws_ec2 as ec2, aws_secretsmanager as sm, aws_rds as rds, aws_logs as logs } from 'aws-cdk-lib';
33
import { Construct } from 'constructs';
44
import { IDatabase, INetworking } from '../interfaces';
55

@@ -82,6 +82,18 @@ export interface DatabaseInstanceProps {
8282
* @default RemovalPolicy.RETAIN
8383
*/
8484
readonly removalPolicy?: cdk.RemovalPolicy;
85+
86+
/**
87+
* The list of log types that need to be enabled for exporting to CloudWatch Logs.
88+
* @default - No log types are enabled.
89+
*/
90+
readonly cloudwatchLogsExports?: string[];
91+
92+
/**
93+
* The number of days log events are kept in CloudWatch Logs. When updating this property, unsetting it doesn't remove the log retention policy. To remove the retention policy, set the value to Infinity.
94+
* @default logs never expire
95+
*/
96+
readonly cloudwatchLogsRetention?: logs.RetentionDays;
8597
}
8698

8799
/**
@@ -151,6 +163,8 @@ export class DatabaseInstance extends Construct implements IDatabase {
151163
storageEncrypted: true,
152164
backupRetention: props.backupRetention,
153165
removalPolicy,
166+
cloudwatchLogsExports: props.cloudwatchLogsExports,
167+
cloudwatchLogsRetention: props.cloudwatchLogsRetention,
154168
});
155169
if (props.networking.bastionHost) {
156170
this.resource.connections.allowDefaultPortFrom(props.networking.bastionHost);

0 commit comments

Comments
 (0)