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

[Bug]: Creating resource aws_wafv2_web_acl_association in same config as aws_wafv2_web_acl often raises WAFUnavailableEntityException #29080

Closed bunmikAgency closed 1 year ago

bunmikAgency commented 1 year ago

Terraform Core Version

1.3.7

AWS Provider Version

4.49.0

Affected Resource(s)

Expected Behavior

Deploy a Load Balancer with a WAF ACL in front of it.

Actual Behavior

Almost half of the time (I tried around 10 times) Terraform errors with WAFUnavailableEntityException. This is already a RetryError in the TF AWS provider code, but presumably the time between ACL creation and load balancer association is still not long enough to get this reproducibly correct.

Relevant Error/Panic Output Snippet

module.waf.aws_wafv2_web_acl_association.load_balancer: Still creating... [5m1s elapsed]

│ Error: creating WAFv2 WebACL Association (arn:aws:wafv2:xx-xxx-x:xxxxxx:xxxxxxx,arn:aws:elasticloadbalancing:xx-xxx-xx:xxxxxxxxx): WAFUnavailableEntityException: AWS WAF couldn’t retrieve the resource that you requested. Retry your request.

Terraform Configuration Files

resource "aws_wafv2_web_acl_association" "example" {
  resource_arn = aws_lb.example.arn
  web_acl_arn  = aws_wafv2_web_acl.example.arn
}

resource "aws_wafv2_web_acl" "example" {
  name  = "alb-example"
  scope = "REGIONAL"

  # some more irrelevant config goes here
}

resource "aws_lb" "example" {
  name = "example"

  # some more irrelevant config goes here
}

Steps to Reproduce

See Actual behavior.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

This issue was raised about 1 year ago where timeout is increased from 2 minutes to 5 minutes and looks like it is still not enough to perform this action.

The previous issue: https://github.com/hashicorp/terraform-provider-aws/issues/17527

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

RichardSilveira commented 1 year ago

The same happened to me. I have added a depends_on section on the aws_wafv2_web_acl_association.

Since often is a keyword here, not sure if that solved the issue 🤔

💥 I'd suggest giving more attention to this item since it's a pretty basic thing to do...

grahamhar commented 1 year ago

I've just looked at the implementation code for this and the timeout is hardcoded at 5 minutes. I think the solution is to add configurable timeouts on the resource in the same way as for things like RDS instances.

bunmikAgency commented 1 year ago

The same happened to me. I have added a depends_on section on the aws_wafv2_web_acl_association.

Since often is a keyword here, not sure if that solved the issue 🤔

💥 I'd suggest giving more attention to this item since it's a pretty basic thing to do...

depends_on wouldn't help here, since depends on resources are implicitly defined.

github-actions[bot] commented 1 year ago

This functionality has been released in v4.59.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 1 year 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.