Skip to content

AWS WAF rules should have CloudWatch metrics enabled

This control checks whether an AWS WAF rule or rule group has Amazon CloudWatch metrics enabled. The control fails if the rule or rule group doesn't have CloudWatch metrics enabled.

How to fix

Attribute visibility_config[0].cloudwatch_metrics_enabled of aws_wafv2_rule_group must be true.

Implementation options

Choose the option that matches how you manage Terraform. All options satisfy this control.

Option 1: Terraform AWS provider resources

If you manage resources directly, configure the relevant Terraform AWS provider resources to meet this control. See docs for the resources involved: aws_wafv2_rule_group.

resource "aws_wafv2_rule_group" "this" {
  capacity = 10
  name     = "pofix-example-rule-group"
  scope    = "REGIONAL"

  visibility_config {
    cloudwatch_metrics_enabled = true
    metric_name                = "pofix-example-metric"
    sampled_requests_enabled   = true
  }
}
Which option should I choose?
  • Compliance.tf module (recommended): controls enforced by default and mapped to frameworks.
  • Open source module (terraform-aws-modules): compatible by design with compliance.tf. Same variable names for an easy, low-change migration path when you are ready.
  • Terraform AWS provider resources: manage Terraform resources directly.

Tool mappings

Use these identifiers to cross-reference this control across tools, reports, and evidence.

  • Compliance.tf (CTF) Control: wafv2_rule_group_logging_enabled

  • AWS Config Managed Rule: WAFV2_RULEGROUP_LOGGING_ENABLED

  • Powerpipe Control: aws_compliance.control.wafv2_rule_group_logging_enabled