Unable to find definitions or declarations in many cases
See original GitHub issueIssue Description
Unable to find definition or declaration
Environment Information
Terraform Information
Version: 1.1.5 Platform: darwin_amd64 Outdated: true
.vscode/extensions/hashicorp.terraform-2.20.0/bin/terraform-ls version:
0.25.2
platform: darwin/amd64
go: go1.17.5
compiler: gc
Visual Studio Code
| Name | Version |
|---|---|
| Operating System | Darwin x64 21.3.0 |
| VSCode | 1.65.2 |
Visual Studio Code Extensions
Visual Studio Code Extensions(Click to Expand)
| Extension | Author | Version |
|---|---|---|
| aws-toolkit-vscode | amazonwebservices | 1.36.0 |
| better-cpp-syntax | jeff-hykin | 1.15.13 |
| cmake | twxs | 0.0.17 |
| cmake-tools | ms-vscode | 1.9.2 |
| code-groovy | marlon407 | 0.1.2 |
| cpptools | ms-vscode | 1.8.4 |
| cpptools-extension-pack | ms-vscode | 1.1.0 |
| cpptools-themes | ms-vscode | 1.0.0 |
| csharp | ms-dotnettools | 1.24.1 |
| doxdocgen | cschlosser | 1.4.0 |
| go | golang | 0.32.0 |
| gradle-language | naco-siren | 0.2.3 |
| java | redhat | 1.4.0 |
| jupyter | ms-toolsai | 2022.2.1030672458 |
| jupyter-keymap | ms-toolsai | 1.0.0 |
| jupyter-renderers | ms-toolsai | 1.0.6 |
| opa | tsandall | 0.10.0 |
| plantuml | jebbs | 2.17.2 |
| python | ms-python | 2022.2.1924087327 |
| remote-containers | ms-vscode-remote | 0.224.2 |
| remote-ssh | ms-vscode-remote | 0.76.1 |
| remote-ssh-edit | ms-vscode-remote | 0.76.1 |
| remote-wsl | ms-vscode-remote | 0.64.2 |
| saltstack | korekontrol | 0.0.9 |
| shell-format | foxundermoon | 7.2.2 |
| synthwave-vscode | RobbOwen | 0.1.11 |
| terraform | hashicorp | 2.20.0 |
| vscode-docker | ms-azuretools | 1.20.0 |
| vscode-jetbrains-keybindings | isudox | 0.1.9 |
| vscode-power-mode | hoovercj | 3.0.1 |
| vscode-pylance | ms-python | 2022.3.1 |
| vscode-yaml | redhat | 1.5.1 |
| xml | DotJoshJohnson | 2.5.1 |
Extension Logs
Find this from the first few lines of the relevant Output pane: View -> Output -> ‘HashiCorp Terraform’
2022/03/13 23:32:59 hover.go:37: Looking for hover data at "vpc_peering.tf" -> hcl.Pos{Line:17, Column:70, Byte:499}
2022/03/13 23:32:59 hover.go:39: received hover data: (*lang.HoverData)(nil)
2022/03/13 23:32:59 rpc_logger.go:45: Error for "textDocument/hover" (ID 90): [-32098] vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
2022/03/13 23:32:59 opts.go:254: Completed 1 requests [14.805875ms elapsed]
[Error - 11:32:59 PM] Request textDocument/hover failed.
Message: vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
Code: -32098
2022/03/13 23:32:59 hover.go:37: Looking for hover data at "vpc_peering.tf" -> hcl.Pos{Line:17, Column:70, Byte:499}
2022/03/13 23:32:59 hover.go:39: received hover data: (*lang.HoverData)(nil)
2022/03/13 23:32:59 rpc_logger.go:45: Error for "textDocument/hover" (ID 97): [-32098] vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
2022/03/13 23:32:59 opts.go:254: Completed 1 requests [17.461433ms elapsed]
[Error - 11:32:59 PM] Request textDocument/hover failed.
Message: vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
Code: -32098
The HCL looks like this:
data "aws_availability_zones" "available" {
}
data "aws_subnet" "private" {
count = var.subnet_count
availability_zone = element(data.aws_availability_zones.available.names, count.index)
tags = {
Type = "private"
}
vpc_id = var.vpc_id
}
Hovering or navigating to usage/definition/declaration doesn’t work in most cases and simply reports that it cannot be found. It can find Data Source Type aws_availability_zones but hovering data.aws_availability_zones.available.names doesn’t do anything, neither does navigating to the declaration of data.aws_availability_zones.available.
Typing data.aws_availability_zones.av doesn’t yield autocompletion for data.aws_availability_zones.available either. It can do data.aws_avail and complete data.aws_availability_zones but beyond that it’s no use.
Other things it can’t find:
- symlinked HCL
- cross-module declarations
- submodule declarations
- Variables in TFVars
I’ve tried to find out if there is a list of known issues for finding usages/definitions but there doesn’t seem to be a detailed “it does not cross this type of boundary” list of things it tries to resolve.
Example of a variable that is filled by tfvars:
variables.tf
variable "namespace" {
description = "The group this environment belongs to. Not optional."
}
environment.auto.tfvars
namespace = "hyperion"
Can’t navigate in either direction via references/declaration.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (5 by maintainers)

Top Related StackOverflow Question
@AlbertoMonteiro This is a known issue we generally track under https://github.com/hashicorp/vscode-terraform/issues/641 or more specifically under https://github.com/hashicorp/terraform-ls/issues/496
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.