umotif-public / terraform-aws-waf-webaclv2

Terraform module to configure WAF V2 Web ACL with managed rules for Application Load Balancer
https://registry.terraform.io/modules/umotif-public/waf-webaclv2/aws
Other
137 stars 124 forks source link

Terraform plan fails after applying using alb_arn_list #34

Closed mgale closed 3 years ago

mgale commented 3 years ago

What is the current behavior? I can use the module as described in the readme to configure an AWS WAF on multiple albs using the alb_arn_list attribute. However on subsequent runs

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

  1. Deploy WAF on multiple ALB's
  2. Running Terraform plan after.

What is the expected behavior?

The second run of terraform plan should complete without error and show no drift.

Software versions? Latest release.

Error message:

Error: Invalid index

  on .terraform/modules/waf/outputs.tf line 33, in output "web_acl_assoc_id":
  33:   value       = var.create_alb_association && var.enabled ? join("", aws_wafv2_web_acl_association.main[0].*.id) : ""
    |----------------
    | aws_wafv2_web_acl_association.main is empty tuple

The given key does not identify an element in this collection value.

Error: Invalid index

  on .terraform/modules/waf/outputs.tf line 38, in output "web_acl_assoc_resource_arn":
  38:   value       = var.create_alb_association && var.enabled ? join("", aws_wafv2_web_acl_association.main[0].*.resource_arn) : ""
    |----------------
    | aws_wafv2_web_acl_association.main is empty tuple

The given key does not identify an element in this collection value.

Error: Invalid index

  on .terraform/modules/waf/outputs.tf line 43, in output "web_acl_assoc_acl_arn":
  43:   value       = var.create_alb_association && var.enabled ? join("", aws_wafv2_web_acl_association.main[0].*.web_acl_arn) : ""
    |----------------
    | aws_wafv2_web_acl_association.main is empty tuple

The given key does not identify an element in this collection value.
seanpascual commented 3 years ago

Hello @mgale

Thanks for sending through your issue. I have created a fix above and once merged will release this as 3.1.1

Once released, please let us know if you run into any further issues so we can investigate.

Cheers,

Sean