I am having the following problem/false postive reported by the vscode-terraform extension for all variables defined in terraform.tfvars files:
An argument named "XXX" is not expected here.

Is there a setting I can set in settings.json to prevent the extension from checking for this in all terraform.tfvars files? Is there a way to know what rule/check of the vscode-terraform extension is triggering this?
My vscode settings for the terraform extension are as follow:
"terraform.path": "/usr/local/bin/terraform",
"terraform.codelens.enabled": true,
"terraform.format": {
"ignoreExtensionsOnSave": [
".tfsmurf"
]
},
"terraform.languageServer": {
"enabled": true,
"args": []
},
"terraform.indexing": {
"enabled": false,
"liveIndexing": false,
"delay": 500,
"exclude": [
".terraform/**/*",
"**/.terraform/**/*"
]
},
"[terraform]": {
"editor.formatOnSave": true,
},
"terraform.telemetry.enabled": false,
}
Thanks.
Could you share more of the variables file? That does not look like the correct way to define vars, but it's hard to judge with the little info provided.
@Dovry
We are using terraform.tfvars to implement variables defined in variables.vars
E.g:
terraform.tfvars
resource_group_name = "myuatrg"
subdomain_name = "uat"
variables.tf
variable "resource_group_name" {
type = string
description = "The name of the resource group."
}
variable "subdomain_name" {
type = string
description = "The name of the DNS subdomain"
}
Does it still complain when you save the files?

Also, which TF version and IDE are you using?
Does it still complain when you save the files?
Yes it does.

Also, which TF version and IDE are you using?
I am using vscode:
code --version
1.38.1
b37e54c98e1a74ba89e03073e5a3761284e3ffb0
x64
✔ 0.12.9 *recent
Switched terraform to version "0.12.9"
terraform --version
Terraform v0.12.9
And the version of the extension is the latest:
code --list-extensions --show-versions | grep -i terra
[email protected]
[email protected]
[email protected]
$:code --version
1.38.1
b37e54c98e1a74ba89e03073e5a3761284e3ffb0
x64
updated from v0.12.7 to latest, still works
$:terraform --version
Terraform v0.12.9
and extensions
$:code --list-extensions --show-versions | grep -i terra
[email protected]
[email protected]
Maybe try disabling the other extensions, and/or reinstalling this one?
I've reinstalled the mauve.terraform extension only and uninstall the rest:
Same issue:

Are you using the language server or you are using indexing?
I found out that the issue disappear if I am not using the language server but then tf0.12 syntax is not supported/checked for anymore.
Is there a way to tweek the rules of the language server by adding some configuration to vscode settings.json?
I have the same behaviour and was also not able to figure out what is causing this. Any help appreciated!
Is there any way to ignore such errors?
Any progress on this, or a way to ignore .tfvars files?
Hate to +1, but I have this exact issue. Seems like a huge problem because using separate tfvars is the only sane way to organize terraform.
same issue also
+1
Same issue, even after uninstalling e reinstalling the extension:
--> code --version
1.40.1
8795a9889db74563ddd43eb0a897a2384129a619
x64
--> terraform --version
Terraform v0.12.13
--> code --list-extensions --show-versions | grep terr
[email protected]
I don't know if it's relevant, this is on an updated Fedora 30.
I have this problem as well:
mauve.[email protected]
run-at-scale.[email protected]
mindginative.[email protected]
1.40.1
8795a9889db74563ddd43eb0a897a2384129a619
x64
Same issue:
--> sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.1
BuildVersion: 19B88
```
--> code --version
1.40.1
8795a9889db74563ddd43eb0a897a2384129a619
x64
--> terraform --version
Terraform v0.12.16
--> code --list-extensions --show-versions | grep terr
mauve.[email protected]
ms-azuretools.[email protected]
```json
--> settings.json
{
"terraform.path": "/usr/local/bin/terraform",
"terraform.codelens.enabled": true,
"terraform.format": {
"ignoreExtensionsOnSave": [
".tfsmurf"
]
},
"terraform.indexing": {
"enabled": false,
"liveIndexing": false,
"delay": 500,
"exclude": [
".terraform/**/*",
"**/.terraform/**/*"
]
},
"terraform.languageServer": {
"enabled": true,
"args": []
},
"[terraform]": {
"editor.formatOnSave": true,
},
"terraform.telemetry.enabled": false
}
Same issue:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G87
$ code --version
1.40.2
f359dd69833dd8800b54d458f6d37ab7c78df520
x64
$ terraform --version
Terraform v0.12.16
$ code --list-extensions --show-versions | grep terr
mauve.[email protected]
$ cat settings.json = {
...
"terraform.languageServer": {
"enabled": true,
"args": []
},
"terraform.indexing": {
"enabled": false,
"liveIndexing": false
}
...
}
same issue
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.1
BuildVersion: 19B88
$ code --version
1.40.2
f359dd69833dd8800b54d458f6d37ab7c78df520
x64
$ terraform --version
Terraform v0.12.16
$ code --list-extensions --show-versions | grep terr
4ops.[email protected]
laszer25.[email protected]
mauve.[email protected]
ms-azuretools.[email protected]
run-at-scale.[email protected]
settings.json
{
...
"terraform.indexing": {
"enabled": false,
"liveIndexing": false,
"delay": 500,
"exclude": [
".terraform//",
"/.terraform//"
]
},
"terraform.languageServer": {
"enabled": true,
"args": []
},
..
}
Same issue:
--> [System.Environment]::OSVersion
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.17763.0 Microsoft Windows NT 10.0.17763.0
--> code --version
1.40.2
f359dd69833dd8800b54d458f6d37ab7c78df520
x64
md5-f09c975f64e9db913ce66de4b51b7b3b
--> terraform --version
Terraform v0.12.16
md5-f09c975f64e9db913ce66de4b51b7b3b
--> code --list-extensions --show-versions | Select-String -Pattern 'terra'
[email protected]
Disabling languageServer in sessions.json makes this error disappear.
"terraform.languageServer": {
"enabled": false
}
This issue can be closed.
terraform-lsp doesn't support tfvars format.
Open Issue for that: https://github.com/juliosueiras/terraform-lsp/issues/39
This issue is related to terraform-lsp and not vscode-terraform.
A terraform-lsp issue has been opened here: juliosueiras/terraform-lsp#39
I understand this this problem is related to the language server, however would it be possible to get a work around of having the language server disabled just for files of type *.tfvars?
(admittedly I don't have a good understanding of language servers, so maybe this question doesn't make sense)
Disabling
languageServerinsessions.jsonmakes this error disappear.Settings.json
"terraform.languageServer": { "enabled": false }This issue can be closed.
But breaks everything else as tf12 is not supported without LSP afair.
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 context necessary to investigate further.
Most helpful comment
I have the same behaviour and was also not able to figure out what is causing this. Any help appreciated!