WAF Logging Disabled
waf-logging-disabled
What this rule checks
Detects WAFv2 WebACLs without logging configuration for analysed requests.
How to fix it
- 1Create an AWS::WAFv2::LoggingConfiguration for the WebACL
import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
new wafv2.CfnWebACL(this, 'Acl', {
scope: 'REGIONAL',
defaultAction: { block: {} },
visibilityConfig: { cloudWatchMetricsEnabled: true, metricName: 'acl', sampledRequestsEnabled: true },
rules: [{
name: 'AWSCommon',
priority: 0,
overrideAction: { none: {} },
statement: { managedRuleGroupStatement: { vendorName: 'AWS', name: 'AWSManagedRulesCommonRuleSet' } },
visibilityConfig: { cloudWatchMetricsEnabled: true, metricName: 'common', sampledRequestsEnabled: true },
}],
});import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
const acl = new wafv2.CfnWebACL(this, 'Acl', {
scope: 'REGIONAL',
defaultAction: { block: {} },
visibilityConfig: { cloudWatchMetricsEnabled: true, metricName: 'acl', sampledRequestsEnabled: true },
rules: [{
name: 'AWSCommon',
priority: 0,
overrideAction: { none: {} },
statement: { managedRuleGroupStatement: { vendorName: 'AWS', name: 'AWSManagedRulesCommonRuleSet' } },
visibilityConfig: { cloudWatchMetricsEnabled: true, metricName: 'common', sampledRequestsEnabled: true },
}],
});
new wafv2.CfnLoggingConfiguration(this, 'AclLogging', {
resourceArn: acl.attrArn,
logDestinationConfigs: ['arn:aws:logs:us-east-1:111122223333:log-group:aws-waf-logs-example'],
});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::WAFv2::WebACLAWS::WAFv2::LoggingConfigurationIntentional? Suppress this finding
Sometimes a flag is deliberate โ a genuinely public endpoint, say. You can dismiss waf-logging-disabled and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "waf-logging-disabled", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::waf-logging-disabled',
reason: 'Why this is intentional',
});Use the rule ID waf-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.