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.61k stars 9k forks source link

Error when referencing AWS WAFv2 IP set ARN in WebACL rule #35903

Open Viswajenny opened 4 months ago

Viswajenny commented 4 months ago

Description

WAF web acl rule fails when created by aws_wafv2_web_acl resource. Works well from the aws console.

Expected Behavior

The WebACL rule that refers the AWS WAFv2 IP set ARN should be successfully created or updated and AWS resources (WebACL and IP set)should be provisioned in AWS with the terraform configuration, and manually creating the same resources in the AWS Management Console works without issues.

Actual Behavior

experiencing the below issue while referencing an AWS WAFv2 IP set ARN in a WebACL rule

Error: updating WAFv2 WebACL (XXXXXXX): WAFInvalidParameterException: Error reason: A reference in your rule statement is not valid., field: RULE, parameter: Statement { RespMetadata: { StatusCode: 400, RequestID: "XXXXX" }, Field: "RULE", Message_: "Error reason: A reference in your rule statement is not valid., field: RULE, parameter: Statement", Parameter: "Statement", Reason: "A reference in your rule statement is not valid." }

Relevant Error/Panic Output Snippet

image

Terraform Configuration Files

Title: Error when referencing AWS WAFv2 IP set ARN in WebACL rule

Description: I am encountering an issue when referencing an AWS WAFv2 IP set ARN in a WebACL rule using Terraform. The ARN is valid, and the same configuration works when manually set up in the AWS Management Console, but it fails during Terraform apply.

Terraform Configuration:

resource "aws_wafv2_web_acl" "rate-limiter" {
  # ... other configurations

  rule {
    name     = "allow-from-yaxxa"
    priority = 3
    statement {
      ip_set_reference_statement {
        arn = aws_wafv2_ip_set.yaxxa_ip_set.arn
      }
    }
    # ... other configurations
  }

  # ... other configurations
}

resource "aws_wafv2_ip_set" "yaxxa_ip_set" {
  # ... other configurations
}

Steps to Reproduce

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 4 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 3 months ago

Hey @Viswajenny 👋 Thank you for taking the time to raise this! Are you able to supply debug logs (redacted as needed) in case whoever picks this up needs that information?

Viswajenny commented 1 month ago

Hi @justinretzolk, Thank you for responding back, please find the logs below.

run-4seB8VaxgWp41kar-apply-log.txt

Screenshot 2024-05-13 at 11 02 03 AM Screenshot 2024-05-13 at 11 02 26 AM