VladRassokhin / intellij-hcl

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

Plugin can't find modules with Terraform 1.1.x #373

Open gmconte opened 2 years ago

gmconte commented 2 years ago

Since I upgraded from Terraform v1.0.10 to v1.1.3 I found that the plugin is unable to find the standard terraform registry modules, hence the autosuggest doesn't work anymore

I believe that this is due to a change in the modules.json generated, causing the plugin to fail the match between the Source value in the code with the Source value in the json file.

The observed change in modules.json is the following:

modules.json from Terraform v1.0.10

...
      "Source": "terraform-aws-modules/vpc/aws",
...

modules.json from Terraform v1.1.3

...
      "Source": "registry.terraform.io/terraform-aws-modules/vpc/aws",
...

As a workaround, I had to modify all my modules to point to the same full path registry.terraform.io/terraform-aws-modules/xxx which is not ideal, but at least I can work with it

Prerequisites

Installation details

Expected Behavior

The plugin doesn't show any warnings

Actual Behavior

The plugin shows a warning "Cannot locate module locally: Unknown reason" and the auto-complete doesn't work

image

Steps to Reproduce

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

  1. Install terraform v1.1.3
  2. run terraform init -upgrade to refresh the modules.json file
andrewpage commented 2 years ago

Having this same issue on Terraform 1.1.2.

skasukur commented 2 years ago

Same issue with Terraform 1.1.*. I have temporarily reverted to terraform 1.0.11

kleijnweb commented 2 years ago

Same here, downgrade works. You can accept the suggested action, it will create .terraform/modules, the warning disappears and autocomplete works. But it would be much nicer if the plugin would be just detect .terraform/modules in the project root. Now all my submodules have a .terraform directory.

christian-m commented 2 years ago

The format of the Source attribute for Git-URLs has changed too:

modules.json from Terraform v0.15

...
      "Source": "git::git@bitbucket.org:sample/url.git?ref=v1.0",
...

modules.json from Terraform v1.1.3

...
      "Source": "git::ssh://git@bitbucket.org/sample/url.git?ref=v1.0",
...
ohcnkk commented 2 years ago

YouTrack ticket just for reference.

https://youtrack.jetbrains.com/issue/IDEA-287371

https://youtrack.jetbrains.com/issue/IDEA-287371#focus=Comments-27-5743872.0-0

ZeroDeth commented 2 years ago

same issue Goland Build #GO-221.5080.224 and Terraform v1.1.8

voycey commented 2 years ago

@VladRassokhin - Can this be prioritised please? 4+ months for this is kind of ridiculous

mbrancato commented 2 years ago

From the example above, this works for me as workaround - it seems Terraform is being explicit about the registry source now when its implied in the HCL.

module "my_module" {
  source      = "terraform-aws-modules/vpc/aws"
}

works fine when set as

module "my_module" {
  source      = "registry.terraform.io/terraform-aws-modules/vpc/aws"
}
jkroepke commented 2 years ago

Seems fixed in latest version

ohcnkk commented 2 years ago

Yes, this issue is fixed in latest IDE versions. Please refer https://youtrack.jetbrains.com/issue/IDEA-287371. @gmconte May be this issue can be closed.

markmandel commented 1 year ago

I'm still seeing this issue with Terraform 1.3.7