Skip to content

Commit

Permalink
fix: logName
Browse files Browse the repository at this point in the history
  • Loading branch information
badmintoncryer committed Jan 18, 2024
1 parent 4d7374e commit da91441
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 462 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-neptune-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
const retention = props.cloudwatchLogsRetention;
if (retention) {
props.cloudwatchLogsExports?.forEach(logType => {
new logs.LogRetention(this, `${logType}LogRetention`, {
new logs.LogRetention(this, `${logType.value}LogRetention`, {
logGroupName: `/aws/neptune/${this.clusterIdentifier}/${logType.value}`,
role: props.cloudwatchLogsRetentionRole,
retention,
Expand Down
49 changes: 49 additions & 0 deletions packages/@aws-cdk/aws-neptune-alpha/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,55 @@ describe('DatabaseCluster', () => {
});
}).toThrow(/ServerlessScalingConfiguration minCapacity 10 must be less than serverlessScalingConfiguration maxCapacity 5/);
});

test('cloudwatchLogsExports log retention is enabled when configured for multiple logs exports', () => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Cluster', {
vpc,
instanceType: InstanceType.R5_LARGE,
cloudwatchLogsExports: [LogType.AUDIT, new LogType('slowquery')],
cloudwatchLogsRetention: logs.RetentionDays.ONE_MONTH,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
EnableCloudwatchLogsExports: ['audit', 'slowquery'],
});
Template.fromStack(stack).hasResourceProperties('Custom::LogRetention', {
LogGroupName: {
'Fn::Join': [
'',
[
'/aws/neptune/',
{
Ref: 'ClusterEB0386A7',
},
'/audit',
],
],
},
RetentionInDays: 30,
});
Template.fromStack(stack).hasResourceProperties('Custom::LogRetention', {
LogGroupName: {
'Fn::Join': [
'',
[
'/aws/neptune/',
{
Ref: 'ClusterEB0386A7',
},
'/slowquery',
],
],
},
RetentionInDays: 30,
});
});
});

function testStack() {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
"Type": "AWS::Neptune::DBClusterParameterGroup",
"Properties": {
"Description": "A nice parameter group",
"Family": "neptune1",
"Family": "neptune1.2",
"Parameters": {
"neptune_enable_audit_log": "1",
"neptune_query_timeout": "100000"
Expand Down Expand Up @@ -505,6 +505,7 @@
"EnableCloudwatchLogsExports": [
"audit"
],
"EngineVersion": "1.2.1.0",
"KmsKeyId": {
"Fn::GetAtt": [
"DbSecurity381C2C15",
Expand All @@ -524,7 +525,7 @@
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"DatabaseobjectObjectLogRetentionA247AF0C": {
"DatabaseauditLogRetention8A29F5CC": {
"Type": "Custom::LogRetention",
"Properties": {
"ServiceToken": {
Expand Down Expand Up @@ -631,7 +632,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "a8515c042d9c942705087943220417be929ac44f968d8fcef2681681b400c0c0.zip"
"S3Key": "e4afb15788ec44ed9ff3377e1d131ba2768d7b2e2931bc000d1f2005879b3035.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit da91441

Please sign in to comment.