hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.84k stars 9.19k forks source link

aws_wafv2_rule_group missing rate_based_statement #21631

Closed ADF1111 closed 3 years ago

ADF1111 commented 3 years ago

Community Note

Description

The resource aws_wafv2_rule_group is missing the option to implement rate_based_statement rules as described in the documentation. Because of that, it is not possible to implement a rate based rule when deploying AWS WAF Web ACLs with AWS Firewall Manager.

New or Affected Resource(s)

Potential Terraform Configuration

resource "aws_wafv2_rule_group" "HTTPFlood_global" {
  name     = "${var.global_policy_name}-rate-based-HTTPFlood"
  scope    = "CLOUDFRONT"
  capacity = 100
  rule {
    name     = "HTTPGetFloodProtection"
    priority = 0

    action {
      block {}
    }

    statement {
      rate_based_statement {
        limit              = 10000
        aggregate_key_type = "IP"
        scope_down_statement {
          and_statement {
            statement {
              byte_match_statement {
                search_string         = "login"
                positional_constraint = "CONTAINS"

                field_to_match {
                  uri_path {}
                }

                text_transformation {
                  priority = 0
                  type     = "LOWERCASE"
                }

                text_transformation {
                  priority = 1
                  type     = "URL_DECODE"
                }
              }
            }
            statement {
              byte_match_statement {
                search_string         = "get"
                positional_constraint = "EXACTLY"

                field_to_match {
                  method {}
                }

                text_transformation {
                  priority = 1
                  type     = "LOWERCASE"
                }
              }
            }
          }
        }
      }
    }

    visibility_config {
      cloudwatch_metrics_enabled = true
      metric_name                = "HTTPGetFloodProtection"
      sampled_requests_enabled   = true
    }
  }

  visibility_config {
    cloudwatch_metrics_enabled = true
    metric_name                = "HTTPFloodProtection_global"
    sampled_requests_enabled   = true
  }
}

References

justinretzolk commented 3 years ago

Hey @ADF1111 πŸ‘‹ Thanks for taking the time to submit this issue. It looks like this is a duplicate of #20908. We like to try to keep discussions consolidated, so we’re going to close this new issue in favor of #20908.

github-actions[bot] commented 2 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.