Demonstrates the use of a rule group within a Web ACL, including rule overrides.

Terraform Template

resource "aws_wafv2_rule_group" "example" {
  capacity = 10
  name = "example-rule-group"

  rule {
    name = "rule-1"
    priority = 1

    visibility_config {
      cloudwatch_metrics_enabled = false
      metric_name = "friendly-rule-metric-name"
      sampled_requests_enabled = false
    }
  }

  rule {
    name = "rule-to-exclude-a"
    priority = 10

    visibility_config {
      cloudwatch_metrics_enabled = false
      metric_name = "friendly-rule-metric-name"
      sampled_requests_enabled = false
    }
  }

  rule {
    name = "rule-to-exclude-b"
    priority = 15

    visibility_config {
      cloudwatch_metrics_enabled = false
      metric_name = "friendly-rule-metric-name"
      sampled_requests_enabled = false
    }
  }
  scope = "REGIONAL"

  visibility_config {
    cloudwatch_metrics_enabled = false
    metric_name = "friendly-metric-name"
    sampled_requests_enabled = false
  }
}

resource "aws_wafv2_web_acl" "test" {
  name = "rule-group-example"

  rule {
    name = "rule-1"
    priority = 1

    visibility_config {
      cloudwatch_metrics_enabled = false
      metric_name = "friendly-rule-metric-name"
      sampled_requests_enabled = false
    }
  }
  scope = "REGIONAL"

  tags = {
    Tag1 = "Value1"
    Tag2 = "Value2"
  }

  visibility_config {
    cloudwatch_metrics_enabled = false
    metric_name = "friendly-metric-name"
    sampled_requests_enabled = false
  }
}