vscode-terraform: Extension shouldn't check for problems in the .terraform folder

Versions

Extension

v2.24.1

VS Code

Version: 1.71.0 (user setup)
Commit: 784b0177c56c607789f9638da7b6bf3230d47a8c
Date: 2022-09-01T07:36:10.600Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19043
Sandboxed: No

Operating System

Windows

Edition	Windows 10 Enterprise
Version	21H1
Installed on	‎27/‎08/‎2021
OS build	19043.1415
Experience	Windows Feature Experience Pack 120.2212.3920.0

WSL

Ubuntu 20.04.4 LTS

Terraform Version

Terraform v1.2.7

Steps To Reproduce

  1. Create a new main.tf file
  2. Use a module like https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/tree/master/examples/safer_cluster_iap_bastion
  3. terraform init

Expected Behavior

No errors on the “Problems” tab of vscode

Actual Behavior

The extension checks for errors in the .terraform folder, giving an error for file in the “autogen” folder. Looking at the file, it’s templated with Jinja so it gives “Argument or block definition required: An argument or block definition is required here.” before double curly braces.

My code is correct and the module itself works, so seeing the red ball next to the project and folders because of something in the .terraform folder is really annoying.

Additional context

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 18
  • Comments: 19 (4 by maintainers)

Most upvoted comments

We could introduce a similar setting which does support glob patterns…

Yes please! I’m working with a deeply nested repo that has well-known “bad” tf files placed intentionally throughout the hierarchy so that terraform cannot be run from that directory.

As a temporary workaround, you could configure VS Code to purposely exclude the .terraform folder from being watched using files.watcherExclude:

"files.watcherExclude": {
    "**/.terraform/*/**": true,
  }

This of course prevents the Terraform Extension from knowing anything about those files (go to definition, intellisense, etc) , so use with caution.

Here’s what worked for me.

settings.json:

  "files.exclude": {
    "**/.terraform": true,
    "**/.terragrunt": true
  },
  "files.watcherExclude": {
    "**/.terraform": true,
    "**/.terragrunt": true
  },

In the Problems tab, ask it to exclude ignored files:

image

Any updates?

Thanks @jpogran !

That would be an acceptable workaround, although it doesn’t seem to work in my machine. I’ve tried adding it to User, Remote and Workspace and both as **/.terraform/** and **/.terraform/*/** and neither seems to remove the errors. I’ve also restarted VS Code after each change.

Any other ideas?