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.82k stars 9.16k forks source link

AWS WAFv2 doesn't support Scope-down statement for managed_rule_group_statements #19125

Closed brandonpalmer closed 3 years ago

brandonpalmer commented 3 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Terraform v0.14.7 / 0.15.1

Affected Resource(s)

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/wafv2_web_acl For Managed Rules, the Scope-Down is not supported in Terraform. It IS supported in the AWS CLI / AWS SDK

This does work for other rule types (like rate_based_statement statement rules)

Terraform Configuration Files

resource "aws_wafv2_web_acl" "default_alb_rules" {
  name        = "default_alb_waf"
  description = "Default ALB WAF Rules"
  scope       = "REGIONAL"

  default_action {
    allow {}
  }

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

    override_action {
      count {}
    }
    statement {
      managed_rule_group_statement {
        name        = "AWSManagedRulesAmazonIpReputationList"
        vendor_name = "AWS"

        scope_down_statement {
          geo_match_statement {
            country_codes = ["US", "NL"]
          }
        }
      }
    }
    visibility_config {
      cloudwatch_metrics_enabled = true
      metric_name                = "AWS-AWSManagedRulesBotControlRuleSet"
      sampled_requests_enabled   = true
    }
  }
  visibility_config {
    cloudwatch_metrics_enabled = false
    metric_name                = "default_alb_waf"
    sampled_requests_enabled   = false
  }
}

Debug Output

https://gist.github.com/brandonpalmer/6ac46bc9c028fdca6faee038e67aaf56

Panic Output

Expected Behavior

Scope-down should have been applied to rule.

Throws error

  1. terraform apply

Important Factoids

References

rajholla commented 3 years ago

There is open PR to address this: https://github.com/hashicorp/terraform-provider-aws/pull/19407

github-actions[bot] commented 3 years ago

This functionality has been released in v3.50.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 3 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.