Skip to content

aws-opensearchservice: cannot disable logging #29200

@sigJoe

Description

@sigJoe

Describe the bug

Enabling logging on OpenSearch clusters will populate LogPublishingOptions in the output template, but disabling logging leaves LogPublishingOptions empty so the cluster will retain the previous logging config. I don't see any documentation saying that enabling logging is a one-way trip, so I think this is a bug.

Specifically, I'm talking about these logging props:

new es.Domain(scope, id, {
 ...
 logging: {
    slowSearchLogEnabled: false,
    appLogEnabled: false,
    slowIndexLogEnabled: false,
  },
})

Expected Behavior

    "LogPublishingOptions": {
        "ES_APPLICATION_LOGS": {
            "Enabled": false
        },
        "SEARCH_SLOW_LOGS": {
            "Enabled": false
        },
        "INDEX_SLOW_LOGS": {
            "Enabled": false
        }
    },

Current Behavior

    "LogPublishingOptions": {},

Reproduction Steps

const { Stack, Duration } = require('aws-cdk-lib');
const es = require('aws-cdk-lib/aws-opensearchservice');

class PocStack extends Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const cluster = new es.Domain(this, 'OpenSearchCluster', {
      domainName: 'test-opensearch-cluster',
      version: es.EngineVersion.OPENSEARCH_2_11,
      capacity: {
        dataNodes: 1,
        dataNodeInstanceType: "t4g.medium.search",
      },
      ebs: {
        volumeSize: 10,
      },
      logging: {
        appLogEnabled: true,
      }
    });
  }
}

module.exports = { PocStack }

Possible Solution

If you don't need the current behaviour, then have it perform the expected behaviour from above.

If there is a good reason it works that way or you want backwards-compatibility, then maybe have logging props like appLogEnabled default to some non-boolean value (e.g. -1). If left default (not specified by user), then LogPublishingOptions can be empty. If the user explicitly specifies either true or false, then populate the LogPublishingOptions to enable or disable logging as appropriate.

Additional Information/Context

An environment hit the limit on cloudwatch resource policies, so I'm working on a change related to the new (much appreciated) suppressLogsResourcePolicy prop. The way things are currently, I'll have to manually (shudder) disable logging on a cluster to clear up policy space before I can deploy the new multi-cluster logging resource policy.

CDK CLI Version

2.128.0

Framework Version

No response

Node.js Version

v18.18.2

OS

OSX

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-opensearchRelated to the @aws-cdk/aws-opensearchservice packagebugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions