Skip to content

(neptune-alpha): Unable to set custom retention period for multiple CloudWatch log exports #26295

@kscjosep

Description

@kscjosep

Describe the bug

I have created a Neptune cluster with the DatabaseCluster construct via aws-neptune-alpha. I enabled audit and slowquery logging, and I would like to export these logs to CloudWatch. However, I am unable to set a custom retention period for both sets of logs due to a bug related to string interpolation. The build will fail with the error message "Error: There is already a Construct with name [object Object]LogRetention in DatabaseCluster ...". Since the interpolated LogType object always resolves to [object Object], CDK throws errors stating that such a construct already exists when more than one log type is exported.

Expected Behavior

Users should be able to export more than one log type to CloudWatch and set a custom retention period using cloudwatchLogsExports and cloudwatchLogsRetention like so:

this.databaseCluster = new DatabaseCluster(
      this,
      `${name}`,
      {
        ...
        ...
        cloudwatchLogsExports: [new LogType('audit'), new LogType('slowquery')],
        cloudwatchLogsRetention: RetentionDays.ONE_MONTH,
      }
    )

Current Behavior

When a custom retention period is set for more than one log type exported to CloudWatch, the error There is already a Construct with name '[object Object]LogRetention' in DatabaseCluster {databaseCluster name} is thrown.

Reproduction Steps

Instantiate a new Neptune DatabaseCluster instance using aws-neptune-alpha, and enable audit logging and slow query logging. Then enable exporting these logs to CloudWatch with a custom retention period like so:

this.databaseCluster = new DatabaseCluster(
      this,
      `${name}`,
      {
        ...
        ...
        cloudwatchLogsExports: [new LogType('audit'), new LogType('slowquery')],
        cloudwatchLogsRetention: RetentionDays.ONE_MONTH,
      }
    )

Possible Solution

Interpolating the string value of the object instead of the object itself should fix the issue (ie ${logType.value}LogRetention instead of ${logType}LogRetention).

Additional Information/Context

No response

CDK CLI Version

2.87.0

Framework Version

No response

Node.js Version

v19.7.0

OS

macOS/Linux

Language

Typescript

Language Version

3.9.4

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-neptuneRelated Amazon NeptunebugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions