VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 47 forks source link

each.value inspection unresolved reference value when using for_each on resource #251

Closed slessardjr closed 5 years ago

slessardjr commented 5 years ago

Prerequisites

Installation details

Terraform Configuration Files

module "ec2_rancher_server_nodes" {
  source = "" //Hidden for privacy
}

resource "aws_lb_target_group" "rancher-tcp-80" {
  name                 = "rancher-prod-tcp-80"
  port                 = 80
  protocol             = "TCP"
  target_type          = "instance"
  vpc_id               = data.aws_vpc.vpc.id
  deregistration_delay = 300
  proxy_protocol_v2    = false

  health_check {
    protocol            = "HTTP"
    path                = "/healthz"
    port                = 80
    healthy_threshold   = 3
    unhealthy_threshold = 3
    timeout             = 6
    interval            = 10
    matcher             = "200-399"
  }
}

resource "aws_lb_target_group_attachment" "internal_nlb_rancher-server-0-tcp-80" {
  for_each         = toset(module.ec2_rancher_server_nodes.id)
  target_group_arn = aws_lb_target_group.rancher-tcp-80.arn
  target_id        = each.value

Expected Behavior

What should have happened? each.value should not be reporting an error on inspection. terraform apply works. This makes inspection rules fail incorrectly.

Actual Behavior

What actually happened? Inspection reports error with red text stating "Unresolved reference value"

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Add for_each to a resource
  2. Attempt to use each.value
  3. Inspection reports error
  4. Terraform apply works.
VladRassokhin commented 5 years ago

Duplicates #235