question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Members of complex object outputs of modules are reported as unresolved if output referenzes object from array

See original GitHub issue

Installation details

  • IDE version (Help->About->Copy to Clipboard): 2019.3.3 Ultimate
  • intellij-hcl plugin version (Settings->Plugins) 0.7.7
  • Terraform version (terraform -v) Terraform v0.12.20, provider.aws v2.52.0

Terraform Configuration Files

Module output defined with a resource object in a module:

variable "enabled" {
  default = true
}
resource "aws_s3_bucket" {
  count = var.enabled ? 1 : 0
  ...
}
output "bucket" {
  value= var.enabled ? aws_s3_bucket.this_bucket[0] : null
}

and then referenced a member of the modules output object:

module "test" {}

local {
   test= module.test.bucket.bucket
}

Exception

Unresolved reference bucket

Expected Behavior

Members of complex outputs (e.g. ressources) from an array should not be reported as unresolved.

Actual Behavior

terraform apply properly works IDEA displays validation error “Unresolved reference <attribute>”. This seems to have already been partially fixed with 0.7.2 (see #213) however it is still happening for this case with 0.7.7.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
VladRassokhincommented, May 7, 2020

@albuch Seems it’s unresolved due to ternary operator, works fine in case of

output "bucket" {
 value= aws_s3_bucket.this_bucket[0]
}
0reactions
systematicguycommented, Nov 22, 2022

I have a slightly different use case when I employ a proxy local for the terraform_remote_state data:

data "terraform_remote_state" "backend_infra" {
  backend = "s3"
  config = {
    bucket = var.backend_bucket
    key    = var.backend_key
    region = "eu-central-1"
  }
}

locals {
  backend_outputs = data.terraform_remote_state.backend_infra.outputs
  deployment_stage = local.backend_outputs.deployment_stage
}

Wherever I use the proxy local (I do this for sake of brevity on multiple places) it gets highlighted with the same Unresolved reference error. image

IDE: 2022.2.3 (Build #PY-222.4345.23, built on October 10, 2022) HCL Plugin: 222.4345.14 Terraform version: 0.13.5

FWIW, this issue got me thinking: https://github.com/VladRassokhin/intellij-hcl/issues/108#issuecomment-329997796

At the same time ‘unresolved reference’ doesn’t highlight that code as error since ‘terraform_remote_state’ specially marked to contain dynamic properties.

It would be ideal to be able to somehow mark locals to contain dynamic properties

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Structures: Objects and Arrays - Eloquent JavaScript
Many types of information require more than one atom, though. Objects allow us to group values—including other objects—to build more complex structures.
Read more >
rollup.js
rollup function receives an input options object as parameter and returns a Promise that resolves to a bundle object with various properties and...
Read more >
How a load module is created - IBM
An output load module is composed of all input object decks and input load modules processed by the linkage editor. The control dictionaries...
Read more >
Groovy Language Documentation
Boolean expressions; Collections and Arrays; Matchers; Iterators and Enumerations; Maps; Strings; Numbers; Object References; Customizing the truth with ...
Read more >
OMNeT++ - Simulation Manual - Index of - omnetpp.org
In OMNeT++, any module which would be too complex as a single entity can be ... There are two basic constructs in NED...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found