Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: aws_wafv2_web_acl error setting ATP configurations #29154

Closed
wagensveld opened this issue Jan 30, 2023 · 4 comments
Closed

[Bug]: aws_wafv2_web_acl error setting ATP configurations #29154

wagensveld opened this issue Jan 30, 2023 · 4 comments
Labels
bug Addresses a defect in current functionality. service/wafv2 Issues and PRs that pertain to the wafv2 service.

Comments

@wagensveld
Copy link

Terraform Core Version

1.0.2

AWS Provider Version

4.52.0

Affected Resource(s)

  • aws_wafv2_web_acl

Expected Behavior

Expect the rulegroup "AWS-AWSManagedRulesATPRuleSet" to my existing AWS WAF

Actual Behavior

Terraform throws an error saying the config doesn't exist, similar to #28808

Relevant Error/Panic Output Snippet

│ Error: updating WAFv2 WebACL (XXX): WAFInvalidParameterException: Error reason: EXACTLY_ONE_CONDITION_REQUIRED, field: MANAGED_RULE_GROUP_CONFIG, parameter: ManagedRuleGroupConfig
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "XXX"
│   },
│   Field: "MANAGED_RULE_GROUP_CONFIG",
│   Message_: "Error reason: EXACTLY_ONE_CONDITION_REQUIRED, field: MANAGED_RULE_GROUP_CONFIG, parameter: ManagedRuleGroupConfig",
│   Parameter: "ManagedRuleGroupConfig",
│   Reason: "You have used none or multiple values for a field that requires exactly one value."
│ }
│ 
│   with module.waf.aws_wafv2_web_acl.waf,
│   on modules/waf/main.tf line 19, in resource "aws_wafv2_web_acl" "waf":
│   19: resource "aws_wafv2_web_acl" "waf" {
│ 
╵

Terraform Configuration Files

terraform {
  required_version = "1.0.2"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.50.0"
    }
  }
}

provider "aws" {
  region = "eu-west-1"
}

resource "aws_wafv2_web_acl" "waf" {
  name  = "cf-acl"
  scope = "CLOUDFRONT"

  default_action {
    allow {}
  }

  visibility_config {
    cloudwatch_metrics_enabled = true
    metric_name                = "cf-acl-waf-metric"
    sampled_requests_enabled   = true
  }

  rule {
    name     = "AWS-AWSManagedRulesATPRuleSet"
    priority = 9
    statement {
      managed_rule_group_statement {
        name        = "AWSManagedRulesATPRuleSet"
        vendor_name = "AWS"
        managed_rule_group_configs {
          login_path   = "XXX"
          payload_type = "JSON"
          username_field {
            identifier = "XXX"
          }
          password_field {
            identifier = "XXX"
          }
        }
      }
    }
    visibility_config {
      cloudwatch_metrics_enabled = true
      metric_name                = "AWS-AWSManagedRulesATPRuleSet"
      sampled_requests_enabled   = true
    }
  }
}

Steps to Reproduce

Apply the above terraform

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

#28808
Potentially: #28878

Would you like to implement a fix?

None

@wagensveld wagensveld added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Jan 30, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/wafv2 Issues and PRs that pertain to the wafv2 service. label Jan 30, 2023
@denniscaopalm
Copy link

denniscaopalm commented Jan 30, 2023

try the following:

rule {
    name     = "AWS-AWSManagedRulesATPRuleSet"
    priority = 9
    statement {
        managed_rule_group_statement {
            name        = "AWSManagedRulesATPRuleSet"
            vendor_name = "AWS"
            managed_rule_group_configs {
              login_path   = "XXX"
            }
            managed_rule_group_configs {
              payload_type = "JSON"
            }
            managed_rule_group_configs {
              username_field {
                identifier = "XXX"
              }
            }
            managed_rule_group_configs {
              password_field {
                identifier = "XXX"
              }
            }
        
        }
    }
}

@wagensveld
Copy link
Author

Thank you so much, it ended up being that, as well as needing to define override_action

In the end if anyone else bumps into this, the rule block that worked looks like so:

rule {
  name     = "AWS-AWSManagedRulesATPRuleSet"
  priority = 9
  statement {
    managed_rule_group_statement {
      name        = "AWSManagedRulesATPRuleSet"
      vendor_name = "AWS"
      managed_rule_group_configs {
        login_path   = "XXX"
      }
      managed_rule_group_configs {
        payload_type = "JSON"
      }
      managed_rule_group_configs {
        username_field {
          identifier = "XXX"
        }
      }
      managed_rule_group_configs {
        password_field {
          identifier = "XXX"
        }
      }
    }
  }
  override_action {
    none {}
  }
  visibility_config {
    cloudwatch_metrics_enabled = true
    metric_name                = "AWS-AWSManagedRulesATPRuleSet"
    sampled_requests_enabled   = true
  }
}

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/wafv2 Issues and PRs that pertain to the wafv2 service.
Projects
None yet
Development

No branches or pull requests

2 participants