tfparse icon indicating copy to clipboard operation
tfparse copied to clipboard

Missing resource while parsing

Open mirettig opened this issue 6 months ago • 0 comments

The following terraform file results in a missing panos_address block when parsed. I have narrowed down the problem to have something to do with the panos_administrative_tag.main["github"].name references in the tomap block. The resource block appears while parsed when I replace the name reference with a string. I have other working blocks where the names of a resource is used successfully, so it doesn't 100% make sense to me why this one would be an issue.

resource "panos_administrative_tag" "main" {
  location = { device_group = { name = "TestDeviceGroup" } }
  for_each = toset(["source1", "source2"])

  name = each.key
}

resource "panos_address" "main" {
  location = { device_group = { name = "TestDeviceGroup" } }
  for_each = tomap({
    "abc01" = { ip_netmask = "15.10.1.123", tags = [panos_administrative_tag.main["source1"].name] }
    "abc02" = { ip_netmask = "15.10.1.124", tags = [panos_administrative_tag.main["source1"].name] }
    "abc05" = { ip_netmask = "15.20.2.56", tags = [panos_administrative_tag.main["source2"].name] }
  })

  name       = each.key
  ip_netmask = lookup(each.value, "ip_netmask", null)
  tags       = lookup(each.value, "tags", null)
}

Edit: I just found out that it is alphabetically related. If I were to change the 2nd resource to zpanos_address, everything would be parsed correctly and the tags would correctly be the referenced tag name.

mirettig avatar Jun 24 '25 19:06 mirettig