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

4.x release returns error when enabled is false. #91

Open
davidjeddy opened this issue Mar 6, 2023 · 2 comments
Open

4.x release returns error when enabled is false. #91

davidjeddy opened this issue Mar 6, 2023 · 2 comments

Comments

@davidjeddy
Copy link

What is the current behavior?

Failing to plan if enabled set to (bool)false. Using 3.x the error does not happen.

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

module "public_api_cdn" {
  source  = "source_url"
  version = "4.1.2"

  alb_arn     = aws_lb_listener.public_api_https.arn
  enabled     = false // tobool(var.feature_toggles.waf)
  name_prefix = join(var.delimiter, [var.environment, var.application, var.random_string, ])

  visibility_config = {
    cloudwatch_metrics_enabled = false
    metric_name                = join(var.delimiter, [var.environment, var.application, "waf", "metric", "public", "api", var.random_string])
    sampled_requests_enabled   = false
  }
}
terraform init
...
terraform plan
...
│ Error: Invalid index
│ 
│   on .terraform/modules/public_api_cdn/outputs.tf line 28, in output "web_acl_rule_names":
│   28:   value       = [for rule_names in aws_wafv2_web_acl.main[0].rule : rule_names.name if var.enabled]
│     ├────────────────
│     │ aws_wafv2_web_acl.main is empty tuple
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.
╵

What is the expected behavior?

TF plan should exit successfully. The outputs should be wrapped to support dis/enabled resources.

The output sh

Software versions?

david:nygw$ terraform --version
Terraform v1.3.9
on linux_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/aws v4.57.0
+ provider registry.terraform.io/hashicorp/external v2.2.2
+ provider registry.terraform.io/hashicorp/random v3.4.3
+ provider registry.terraform.io/hashicorp/template v2.2.0
+ provider registry.terraform.io/hashicorp/tls v4.0.3
@PLeS207
Copy link

PLeS207 commented Jun 20, 2023

faced with the same issue

@thicksR40
Copy link

thicksR40 commented Aug 22, 2023

Having the same issue on running env and new
Terraform v1.5.4
aws v4.44.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants