Closed radeksimko closed 1 month ago
I suspect this may have something to do with how we compare the modules.json
source address with the source address from the configuration:
i.e. it's likely that we fail to treat github.com/aws-ia/terraform-aws-eks-blueprints?ref=v4.29.0
as equal to git::https://github.com/aws-ia/terraform-aws-eks-blueprints.git?ref=v4.29.0
.
This probably concerns the following code paths:
I'm not sure if this affects other sources, i.e. whether other sources get encoded under different "canonical" address like GitHub does. If not, we may just get away with an extra edge case for GitHub.
Thanks! I can confirm that for my terraform, git::https://github.com
is a viable workaround.
It's also worth pointing out that the official documentation on how to source from github has the address format of github.com/...
https://developer.hashicorp.com/terraform/language/modules/sources#github
I found this issue because i'm having the same problem, and my url format is github.com/org/repo...
and not git::https://github.com...
And this is the error from my vscode:
2023-06-28 10:01:52.375 [error] main.tf (15,13): unknown attribute "status": Error: main.tf (15,13): unknown attribute "status"
at c:\Users\user\.vscode\extensions\hashicorp.terraform-2.26.1-win32-x64\out\extension.js:1:387194
at re (c:\Users\user\.vscode\extensions\hashicorp.terraform-2.26.1-win32-x64\out\extension.js:1:387488)
at c:\Users\user\.vscode\extensions\hashicorp.terraform-2.26.1-win32-x64\out\extension.js:1:382272
at Immediate.<anonymous> (c:\Users\user\.vscode\extensions\hashicorp.terraform-2.26.1-win32-x64\out\extension.js:1:382292)
at processImmediate (node:internal/timers:466:21)
Looking at the terraform init, regardless of what format we put the source in, it always does: Downloading git::https://github.com...
modules.json always has "Source":"git::https://github.com
If there is a comparator in place between the source address from modules.json and the source address from the configuration, can that be changed so that modules.json becomes the source of truth instead?
Changing the format for the source in main.tf
from source = "github.com/
to source = "git::https://github.com/
caused the autocomplete to start working, just as Mat Schaffer pointed out above.
If modules.json
already has this source address format set, couldn't we just use that as the source address so autocomplete works properly?
Are there any updates on this? If i include modules like this
module "globals" {
source = "git@github.com:orga/repo.git//tf_modules//globals"
}
module "this" {
account_id = module.globals... # NO AUTOCOMPLETE
}
it wont work, Intellij works just fine (-:
I am also having similar problem where I am not able to use "Go to definition" on the variables within the module:
module "my_eks" {
source = "github.com/aws-ia/terraform-aws-eks-blueprints?ref=v4.32.1"
...
}
the versions:
❯ ~/.vscode/extensions/hashicorp.terraform-2.28.2-darwin-arm64/bin/terraform-ls --version
0.32.2
Any news on this? Would love to swítch from idea to vscode.
Wondering the same thing, is this issue in any way prioritized? 😕
I see https://github.com/hashicorp/terraform-ls/pull/1760 is supposed to have solved this, but it didn't work for me, though my use case might be a bit different.
We have an iac repo with a lot of tf modules with default parameters and tags, and we reference it with a, for instance, source = "git::https://dev.azure.com/<org>/<project>/_git/<repo-name>//modules/aws/sns/topic_subscription"
.
terraform init
, terraform plan
and terraform apply
work fine and are able to resolve the modules, but neither the hovering nor the autocomplete from this extension work.
For locally declared modules, everything works fine, including modules referencing these problematic modules.
@aspectum interesting discovery! I'm not able to reproduce your issue with a module from the public registry, like
module "alias_no_refresh" {
source = "git::https://github.com/terraform-aws-modules/terraform-aws-lambda.git//modules/alias"
refresh_alias = false
name = "current-no-refresh"
}
Do you mind opening a separate issue, so we can dig into this problem?
@aspectum interesting discovery! I'm not able to reproduce your issue with a module from the public registry, like
module "alias_no_refresh" { source = "git::https://github.com/terraform-aws-modules/terraform-aws-lambda.git//modules/alias" refresh_alias = false name = "current-no-refresh" }
Do you mind opening a separate issue, so we can dig into this problem?
This snippet also fails in my company laptop, but in my personal machine it works. Right now all the versions of everything are the same (terrafom, vscode and the extension). The most obvious difference is the OS: my company laptop runs Windows while my personal runs Linux. I'll try to investigate this a bit more and if I do find more evidence I'll open an issue.
We have just released a new version of vscode-terraform: 2.32.0 which adds support for private git repositories (for initialized environments). The update should show up automatically in VS Code.
I'm closing this issue as completed. In case you experience any problems, please do let us know.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
I'm getting an error after
terraform init
on v2.26.1 of the plugin (terraform-ls 0.31.2)With just this HCL:
But I can see the variable in the locally-downloaded copy as expected:
Originally posted by @matschaffer-roblox in https://github.com/hashicorp/vscode-terraform/issues/1181#issuecomment-1556381720