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.85k stars 9.2k forks source link

[WAFv2] aws_wafv2_web_acl capacity attribute's value is not updated correctly #39867

Open uyggnodoow opened 1 month ago

uyggnodoow commented 1 month ago

Description

Hello 👋

It's not clear if this is actually an issue with Terraform, here are the issues I've encountered.


We removed a few rules through the WAF deployment using terraform.

Before deployment, the WebACL's WCUs is 2630, but the rule removal should reduce the WCUs by 1000 or so.

I actually deployed it, and it looks fine in the AWS management console: (2630 - > 1645)

However, in the CLI, it looks like this

Plan: 0 to add, 1 to change, 0 to destroy.

Changes to Outputs:
  ~ aws_wafv2_capacity                         = 2630 -> 2645

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_wafv2_web_acl.this: Modifying... [id=]
aws_wafv2_web_acl.this: Modifications complete after 4s [id=]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Outputs:

aws_wafv2_arn = ""
aws_wafv2_capacity = 2645

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 3 weeks ago

Hey @uyggnodoow 👋 Thank you for taking the time to raise this! So that we have the necessary information in order to review this, can you provide a sample Terraform configuration that can be used to reproduce this and/or debug logging (redacted as needed)?

uyggnodoow commented 3 weeks ago

Hey @justinretzolk

Thanks for response. The Terraform modules I'm using are listed below. You can refer to the examples folder to configure your rules.

justinretzolk commented 2 weeks ago

Thanks for that information @uyggnodoow. One more question before I remove the needs-triage label and let the team or community prioritize this as we're able to: if you run terraform apply again, is the value updated to the correct value?

uyggnodoow commented 4 days ago

Hello, @justinretzolk

I apologize for the delay in responding.

It does not show 'No Changes' even though there is no change in the policy. It shows the change in 'aws_wafv2_capacity'.

# terragrunt plan
...

aws_wafv2_web_acl.this: Refreshing state... [id=67db98df-342f-42c5-9395-5d6fee941e7a]
aws_wafv2_web_acl_logging_configuration.this[0]: Refreshing state... [id=arn:aws:wafv2:ap-northeast-2::regional/webacl//67db98df-342f-42c5-9395-5d6fee941e7a]

Changes to Outputs:
  ~ aws_wafv2_capacity                         = 2630 -> 1630

You can apply this plan to save these new output values to the Terraform
state, without changing any real infrastructure.

# terragrunt apply
...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

aws_wafv2_arn = "arn:aws:wafv2:ap-northeast-2::regional/webacl//67db98df-342f-42c5-9395-5d6fee941e7a"
aws_wafv2_capacity = 1630