VladRassokhin / intellij-hcl

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

Interpolation of for_each iterator is marked as an error #253

Closed G-Rath closed 5 years ago

G-Rath commented 5 years ago

Prerequisites

Installation details

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
G-Rath commented 5 years ago

This is from the same code as #252, but I made them as two issues as I figured it'd be easier to tackle.

I'm not sure what's going on w/ the state of this plugin open/close-source wise, but I'd be happy to contribute PRs :)

VladRassokhin commented 5 years ago

Is dynamic "ingress" block just in file or inside some resource?

I'm not sure what's going on w/ the state of this plugin open/close-source wise, but I'd be happy to contribute PRs :)

Due to closed sources nature it makes no sense to create PR :( Anyway thanks for opening an issue.

mdaniel commented 5 years ago

Due to closed sources nature it makes no sense to create PR :( Anyway thanks for opening an issue.

Then might I suggest you should close the three open PRs and provide an update on #222?

G-Rath commented 5 years ago

Is dynamic "ingress" block just in file or inside some resource?

Sorry that's my bad - I thought I'd copied the whole block!

resource "aws_security_group" "server" {
  name        = "${var.env_prefix}-server"
  description = "server security group"
  vpc_id      = var.vpc_id

  # Allow HTTP from anywhere
  ingress {
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  # Allow HTTPS from anywhere
  ingress {
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  # 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)"
    }
  }
}

Due to closed sources nature it makes no sense to create PR

I know, but wanted to register my interest in helping if that ever becomes possible. It's just that there's a number small-ish issues open that I'd personally have been happy to dive into (basic spell checking, among a few others), but can't :(

While @mdaniel might come across as a bit strong, he isn't wrong that it'd be nice to have a bit of info about the state of this plugin :)

In the meantime, I'm happy to keep opening issues if they're beneficial.

j-martin commented 5 years ago

The same issue happens with resources (unsurprisingly enough). They are now supported in 0.12.6.

https://www.terraform.io/docs/configuration/resources.html#for_each-multiple-resource-instances-defined-by-a-map-or-set-of-strings

VladRassokhin commented 5 years ago

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

G-Rath commented 4 years ago

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").