OpenSearch Logging Disabled
opensearch-logging-disabled
What this rule checks
Detects OpenSearch domains without audit logs or application logs published to CloudWatch.
How to fix it
- 1Enable AUDIT_LOGS in LogPublishingOptions
- 2Enable ES_APPLICATION_LOGS in LogPublishingOptions
import { CfnDomain } from 'aws-cdk-lib/aws-opensearchservice';
new CfnDomain(this, 'SearchDomain', {
engineVersion: 'OpenSearch_2.11',
clusterConfig: { instanceType: 'r6g.large.search', instanceCount: 2 },
vpcOptions: {
subnetIds: ['subnet-0abc123'],
securityGroupIds: ['sg-0def456'],
},
encryptionAtRestOptions: { enabled: true },
nodeToNodeEncryptionOptions: { enabled: true },
domainEndpointOptions: { enforceHttps: true },
advancedSecurityOptions: {
enabled: true,
internalUserDatabaseEnabled: false,
masterUserOptions: {
masterUserArn: 'arn:aws:iam::111122223333:role/OpenSearchAdmin',
},
},
});import { CfnDomain } from 'aws-cdk-lib/aws-opensearchservice';
const logArn =
'arn:aws:logs:us-east-1:111122223333:log-group:/aws/opensearch/search:*';
new CfnDomain(this, 'SearchDomain', {
engineVersion: 'OpenSearch_2.11',
clusterConfig: { instanceType: 'r6g.large.search', instanceCount: 2 },
vpcOptions: {
subnetIds: ['subnet-0abc123'],
securityGroupIds: ['sg-0def456'],
},
encryptionAtRestOptions: { enabled: true },
nodeToNodeEncryptionOptions: { enabled: true },
domainEndpointOptions: { enforceHttps: true },
advancedSecurityOptions: {
enabled: true,
internalUserDatabaseEnabled: false,
masterUserOptions: {
masterUserArn: 'arn:aws:iam::111122223333:role/OpenSearchAdmin',
},
},
logPublishingOptions: {
AUDIT_LOGS: { enabled: true, cloudWatchLogsLogGroupArn: logArn },
ES_APPLICATION_LOGS: { enabled: true, cloudWatchLogsLogGroupArn: logArn },
},
});CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.
Affected resource types
AWS::OpenSearchService::DomainAWS::Elasticsearch::DomainIntentional? Suppress this finding
Sometimes a flag is deliberate โ a genuinely public endpoint, say. You can dismiss opensearch-logging-disabled and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "opensearch-logging-disabled", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::opensearch-logging-disabled',
reason: 'Why this is intentional',
});Use the rule ID opensearch-logging-disabled shown above โ not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs โ
Catch this in your stack
$ npx cdk-insights scanCDK Insights runs this and 118+ other rules locally against your synthesised CDK app โ free, no account, your code never leaves your machine.