Blocks of type "custom_key" are not expected here in waf2

I am writing a WAFv2 rule with rate_based_statement with aggregate_key value as CUSTOM_KEYS. Following documentations

Here is my code example snippet

rule {
    name     = "waf2rule-rate-limit-query_string"
    priority = 12
    action {
      count {
      }
    }
    statement {
      rate_based_statement {
        limit              = 10000
        aggregate_key_type = "CUSTOM_KEYS"
        custom_key {
          query_string {
            text_transformation {
              priority = 1
              type     = "HTML_ENTITY_DECODE"
            }
            text_transformation {
              priority = 2
              type     = "URL_DECODE"
            }
          }
        }
      }
    }
    visibility_config {
      cloudwatch_metrics_enabled = true
      metric_name                = "waf2rule-rate-limit-query_string"
      sampled_requests_enabled   = true
    }
  }

Although the official documentation has some error and ambiguity mentioning the block key name as custom_keys and custom_key


being not sure which one to use I tried both but I keep getting below error

Error: Unsupported block type
│ 
│   on terraform.tf line 3913, in resource "aws_wafv2_rule_group" "rule-groupe":
│ 3913:         custom_key {
│ 
│ Blocks of type "custom_key" are not expected here.

Below is my prover version

aws = {
      source  = "hashicorp/aws"
      version = "~> 4.16"
    }

I’ll greatly appreciate anyone who can help me here or by correcting me. I am looking to get some help ASAP as it’s a bit urgent issue. Thank you!

hi @Utshab500

You’ve linked to the documentation for 5.69, but you are using 4.16. That block probably did not exist in the version you are using.

2 Likes

Thanks, @jbardin yes you pointed it right, I also realized that. I updated the provider version already. It’s working now.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.