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.

Interpolation of for_each iterator is marked as an error

See original GitHub issue

Prerequisites

  • Ensure you have latest version of plugin installed
  • Search for possible issue duplicates

Installation details

  • IDE version (Help->About->Copy to Clipboard)
  • intellij-hcl plugin version (Settings->Plugins) 0.7.5
  • Terraform version (terraform -v) 0.12.7
IntelliJ Version details IntelliJ IDEA 2019.2.1 (Ultimate Edition) Build #IU-192.6262.58, built on August 21, 2019 Licensed to Gareth Jones Subscription is active until June 22, 2020 Runtime version: 11.0.2+9-b226.7 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1981M Cores: 8 Registry: analyze.exceptions.on.the.fly=true, java.completion.argument.hints.internal=false, git.use.builtin.ssh=true, debugger.watches.in.variables=false, completion.stats.show.ml.ranking.diff=true Non-Bundled Plugins: CMD Support, Key Promoter X, PsiViewer, Switch Structure, com.alayouni.ansiHighlight, com.intellij.apacheConfig, com.jetbrains.foldOtherMethods, com.jetbrains.plugins.ini4idea, com.intellij.plugins.watcher, lermitage.intellij.battery.status, mobi.hsz.idea.gitignore, net.seesharpsoft.intellij.plugins.csv, net.vektah.codeglance, org.asciidoctor.intellij.asciidoc, org.elixir_lang, org.intellij.plugins.hcl, Karma, com.dmarcotte.handlebars, com.intellij.lang.jsgraphql, com.intellij.plugins.html.instantEditing, com.intellij.plugins.webcomponents, com.jetbrains.lang.ejs, com.jetbrains.plugins.jade, com.jetbrains.php, com.jetbrains.php.blade, com.jetbrains.php.drupal, com.jetbrains.php.wordPress, com.jetbrains.twig, de.espend.idea.laravel, net.king2500.plugins.PhpAdvancedAutoComplete, cucumber-javascript, intellij.prettierJS, org.intellij.scala, org.jetbrains.plugins.go, org.jetbrains.plugins.phpstorm-remote-interpreter, org.jetbrains.plugins.vagrant, org.jetbrains.plugins.vue, Dart, org.jetbrains.plugins.node-remote-interpreter, Pythonid, com.emberjs, com.raket.silverstripe, org.jetbrains.plugins.ruby, jones.foldtestblocks.fold-test-blocks, org.psliwa.idea.composer, org.sylfra.idea.plugins.linessorter, org.toml.lang, org.rust.lang, ru.adelf.idea.dotenv, uk.co.ben-gibson.remote.repository.mapper

Terraform Configuration Files

locals {
  admin_locations = [
    {
      cidr_range  = "xx.xxx.xxx.xxx/xx",
      description = "Office"
    }
  ]
}

# Allow SSH from our designated admin locations
dynamic "ingress" {
  for_each = local.admin_locations
  iterator = location

  content {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    description = "${location.value.description} (MySQL access)"
  }
}

Exception

None, nor anything in the logs.

Expected Behavior

No errors.

Actual Behavior

${location.value.description} is marked w/ the error “Unknown resource type”.

Steps to Reproduce

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

  1. Write sample code into .tf file

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
VladRassokhincommented, Sep 12, 2019

Actually it’s already fixed as part of #224 fix, though not released. Will be available in 0.7.6

0reactions
G-Rathcommented, Sep 1, 2020

This still happens with for:

resource "aws_acm_certificate" "cert" {
  domain_name               = var.primary_domain_name
  subject_alternative_names = var.secondary_domain_names
  validation_method         = "DNS"
}

output "staging_cert_domain_validation_records" {
  value = [
    for dvo in aws_acm_certificate.cert.domain_validation_options :
    "${dvo.domain_name} ${dvo.resource_record_name} ${dvo.resource_record_type} ${dvo.resource_record_value}"
  ]
}

In the above dvo.domain_name & co are marked as errors, with dvo being marked with warning ("unknown resource’), and the properties being marked as errors (“unresolved reference”).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot assign to item because it is a foreach iteration variable
EDIT: This question is different to the possible duplicate because it's asking why we can't modify the iteration variable when behind the scenes ......
Read more >
Data factory - ForEach Activity error - Next on empty iterator
I have created a pipeline with two nested foreach activities. The first one is extracting a list of files to load. The second...
Read more >
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
Perl | Loops (for, foreach, while, do...while, until, Nested loops)
A foreach loop is used to iterate over a list and the variable holds the value of the elements of the list one...
Read more >
Loop variable built-ins - Apache FreeMarker Manual
Hence, this is a parsing error: ... Tells if the item where the iteration (which is identified by the loop variable name) currently...
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