AWS WAF rules should have CloudWatch metrics enabled
Checks that CloudWatch metrics are enabled on the AWS WAF rule group and on every rule in it; it passes only when all of them are on. Without metrics you cannot see which rules match traffic or alarm on them. An empty rule group is judged on its own setting, where AWS reports the control as not applicable.
- service
- WAF
- severity
- Medium
- scope
- evaluated in every region
How to fix it
- Overwrites existing settings: The CLI call and the Terraform resource replace the whole rule group: include every rule get-rule-group lists, each with metrics on, or the rules you leave out are deleted.
In the console
AWS WAF → Rule groups → the scope and Region → the rule group → Visibility configuration
- Rule group VisibilityConfig.
CloudWatchMetricsEnabled - true
- Each rule's VisibilityConfig.
CloudWatchMetricsEnabled - true on every rule; in the console, set it in each rule's JSON editor
With the AWS CLI
aws wafv2 update-rule-group --name <name> --scope REGIONAL --id <rule-group-id> --lock-token <lock-token> --visibility-config '{"SampledRequestsEnabled":true,"CloudWatchMetricsEnabled":true,"MetricName":"<metric-name>"}' --rules file://rules.json --region <region>With Terraform
resource "aws_wafv2_rule_group" "this" {
name = var.name
capacity = var.capacity
scope = "REGIONAL"
visibility_config {
cloudwatch_metrics_enabled = true
metric_name = var.metric_name
sampled_requests_enabled = true
}
}
See which of your accounts this check is failing on.
Book a live scan