Skip to content

Commit 56794fc

Browse files
fix(neptune-alpha): multiple cloudwatchLogsExports cannot be set when configuring log retention (#28643)
This PR includes a breaking change to the aws-neptune-alpha module. I have resolved an issue where it was not possible to set multiple `cloudwatchLogsExports` when configuring log retention for a `DatabaseCluster`. The root cause of the problem was that the LogRetention creation included `[object object]` in the construct's ID. With the current fix, the given `logType` can now be correctly included in the `LogRetention`. ```diff - new logs.LogRetention(this, `${logType}LogRetention`, {..} // "DatabaseobjectObjectLogRetentionA247AF0C" + new logs.LogRetention(this, `${logType.value}LogRetention`, {..} // "DatabaseauditLogRetention8A29F5CC" ``` BREAKING CHANGE: Corrected LogRetention IDs for DatabaseCluster. Previously, regardless of the log type, the string ‘objectObject’ was always included, but after the correction, the log type is now included. Closes #26295. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 990ead3 commit 56794fc

File tree

14 files changed

+83
-462
lines changed

14 files changed

+83
-462
lines changed

packages/@aws-cdk/aws-neptune-alpha/lib/cluster.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ export class DatabaseCluster extends DatabaseClusterBase implements IDatabaseClu
633633
const retention = props.cloudwatchLogsRetention;
634634
if (retention) {
635635
props.cloudwatchLogsExports?.forEach(logType => {
636-
new logs.LogRetention(this, `${logType}LogRetention`, {
636+
new logs.LogRetention(this, `${logType.value}LogRetention`, {
637637
logGroupName: `/aws/neptune/${this.clusterIdentifier}/${logType.value}`,
638638
role: props.cloudwatchLogsRetentionRole,
639639
retention,

packages/@aws-cdk/aws-neptune-alpha/test/cluster.test.ts

+49
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,55 @@ describe('DatabaseCluster', () => {
830830
});
831831
}).toThrow(/ServerlessScalingConfiguration minCapacity 10 must be less than serverlessScalingConfiguration maxCapacity 5/);
832832
});
833+
834+
test('cloudwatchLogsExports log retention is enabled when configured for multiple logs exports', () => {
835+
// GIVEN
836+
const stack = testStack();
837+
const vpc = new ec2.Vpc(stack, 'VPC');
838+
839+
// WHEN
840+
new DatabaseCluster(stack, 'Cluster', {
841+
vpc,
842+
instanceType: InstanceType.R5_LARGE,
843+
cloudwatchLogsExports: [LogType.AUDIT, new LogType('slowquery')],
844+
cloudwatchLogsRetention: logs.RetentionDays.ONE_MONTH,
845+
});
846+
847+
// THEN
848+
Template.fromStack(stack).hasResourceProperties('AWS::Neptune::DBCluster', {
849+
EnableCloudwatchLogsExports: ['audit', 'slowquery'],
850+
});
851+
Template.fromStack(stack).hasResourceProperties('Custom::LogRetention', {
852+
LogGroupName: {
853+
'Fn::Join': [
854+
'',
855+
[
856+
'/aws/neptune/',
857+
{
858+
Ref: 'ClusterEB0386A7',
859+
},
860+
'/audit',
861+
],
862+
],
863+
},
864+
RetentionInDays: 30,
865+
});
866+
Template.fromStack(stack).hasResourceProperties('Custom::LogRetention', {
867+
LogGroupName: {
868+
'Fn::Join': [
869+
'',
870+
[
871+
'/aws/neptune/',
872+
{
873+
Ref: 'ClusterEB0386A7',
874+
},
875+
'/slowquery',
876+
],
877+
],
878+
},
879+
RetentionInDays: 30,
880+
});
881+
});
833882
});
834883

835884
function testStack() {

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/ClusterTestDefaultTestDeployAssert6A1BBA9D.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/asset.a8515c042d9c942705087943220417be929ac44f968d8fcef2681681b400c0c0/index.d.ts

-14
This file was deleted.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/asset.a8515c042d9c942705087943220417be929ac44f968d8fcef2681681b400c0c0/index.js

-192
This file was deleted.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/asset.a8515c042d9c942705087943220417be929ac44f968d8fcef2681681b400c0c0/index.ts

-229
This file was deleted.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/asset.e4afb15788ec44ed9ff3377e1d131ba2768d7b2e2931bc000d1f2005879b3035/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/aws-cdk-neptune-integ.assets.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/aws-cdk-neptune-integ.template.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@
430430
"Type": "AWS::Neptune::DBClusterParameterGroup",
431431
"Properties": {
432432
"Description": "A nice parameter group",
433-
"Family": "neptune1",
433+
"Family": "neptune1.2",
434434
"Parameters": {
435435
"neptune_enable_audit_log": "1",
436436
"neptune_query_timeout": "100000"
@@ -505,6 +505,7 @@
505505
"EnableCloudwatchLogsExports": [
506506
"audit"
507507
],
508+
"EngineVersion": "1.2.1.0",
508509
"KmsKeyId": {
509510
"Fn::GetAtt": [
510511
"DbSecurity381C2C15",
@@ -524,7 +525,7 @@
524525
"UpdateReplacePolicy": "Delete",
525526
"DeletionPolicy": "Delete"
526527
},
527-
"DatabaseobjectObjectLogRetentionA247AF0C": {
528+
"DatabaseauditLogRetention8A29F5CC": {
528529
"Type": "Custom::LogRetention",
529530
"Properties": {
530531
"ServiceToken": {
@@ -631,7 +632,7 @@
631632
"S3Bucket": {
632633
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
633634
},
634-
"S3Key": "a8515c042d9c942705087943220417be929ac44f968d8fcef2681681b400c0c0.zip"
635+
"S3Key": "e4afb15788ec44ed9ff3377e1d131ba2768d7b2e2931bc000d1f2005879b3035.zip"
635636
},
636637
"Role": {
637638
"Fn::GetAtt": [

packages/@aws-cdk/aws-neptune-alpha/test/integ.cluster.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)