HashiCorp Terraform for VS Code: two settings that cut provider-doc lookups

HashiCorp Terraform for VS Code: two settings that cut provider-doc lookups

HashiCorp Terraform for VS Code (v2.39.3, 6.4M installs) ships two off-by-default settings worth enabling: `prefillRequiredFields` auto-inserts every required resource attribute as a tab-stop snippet, and `mcp.server.enable` wires GitHub Copilot to live Terraform Registry data via a containerized MCP server — eliminating training-data guesses on provider schemas.

VS Code / JetBrains Plugin Pick
June 10, 2026 · 1:26 AM
1 subscriptions · 23 items
Most developers who install the HashiCorp Terraform extension (HashiCorp.terraform, 6.4 million installs 1) leave two features disabled by default. One auto-populates every required attribute when you autocomplete a resource block. The other wires GitHub Copilot (or Cursor) directly to live Terraform Registry data, so the AI stops guessing at provider schemas.
Both are off. Both are worth turning on.
Extension ID: HashiCorp.terraform · Publisher: HashiCorp · Version: v2.39.3 (released 2026-03-04) · License: MPL-2.0 · Install on VS Code Marketplace

The pre-fill trick: tab through required fields instead of typing them

Every time you write a new resource block, you need to know which attributes are required and what they're called. The workflow is to open the provider docs, read the schema, type the attribute names, then type placeholder values. On a busy day that lookup happens a dozen times.
terraform.experimentalFeatures.prefillRequiredFields changes that. 1 When it's enabled, completing a resource block inserts all required fields as a snippet — each attribute pre-named, each value a tab stop. You tab through them in order, filling in only the actual values.
Add these two lines to your settings.json:
"terraform.experimentalFeatures.prefillRequiredFields": true,
"editor.suggest.preview": true
The second setting enables the inline ghost-text preview so you can see the full block structure before accepting the suggestion. 1
Here's what it looks like before you press Tab:
IntelliSense dropdown showing aws_alb_listener selected, with the complete resource block structure previewed in ghost text alongside required attributes
Pre-fill ghost-text preview — accept the suggestion and the full skeleton appears with tab stops on load_balancer_arn, default_action, port, and protocol. 1
And after accepting:
Minimal aws_alb_listener resource block with load_balancer_arn and default_action pre-populated with value placeholders
The inserted snippet — cursor starts on the first required field. Tab moves to the next. 1
This works for resource, data, provider, variable, output, module, and Terraform Stacks components. The attribute list comes from terraform-ls (the bundled language server) reading the provider schema, so it's accurate to whichever provider version you have initialized. 2
One caveat worth knowing: the feature is tagged experimentalFeatures for a reason. It's stable for common AWS/GCP/Azure resources, but edge cases with complex nested blocks or custom providers occasionally drop you into a partial snippet. That's the trade-off — provider-doc lookup every time vs. tab-through with occasional cleanup.

MCP Server: give Copilot live Registry data instead of training guesses

The second setting is more recent and has a hard prerequisite: Docker or Podman must be installed and running.
"terraform.mcp.server.enable": true
This launches hashicorp/terraform-mcp-server:1.0.0 3 as a container and registers it with VS Code's MCP layer. GitHub Copilot in Agent mode can then call 46 tools — 9 for querying the public Terraform Registry (providers, modules, policies), 4 for private registry lookups, and 27 for HCP Terraform workspace management. 3
Loading content card…
Why does this matter? By default, Copilot generates Terraform from its training data — which means it produces plausible-looking HCL with attribute names that may not exist in the current provider version, or misses new arguments added after its cutoff. The MCP server intercepts those queries and answers them with live Registry responses.
HashiCorp's own advice in their blog on the MCP server updates: "start your prompt with #terraform or #vault. This forces the AI to check the MCP server for the real answer." 4 Without the prefix, the model may generate from training data and skip the tool call.
A prompt like this in Copilot Chat:
#terraform Create an AWS S3 bucket with versioning enabled and server-side encryption using the latest AWS provider
routes through search_providersget_latest_provider_versionget_provider_capabilities before generating HCL — the output reflects the current provider schema rather than a snapshot from training. 5

Both settings together: copy-paste config

The full settings.json block combining both features:
{
  "terraform.mcp.server.enable": true,
  "terraform.experimentalFeatures.prefillRequiredFields": true,
  "editor.suggest.preview": true,
  "[terraform]": {
    "editor.defaultFormatter": "hashicorp.terraform",
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file"
  },
  "[terraform-vars]": {
    "editor.defaultFormatter": "hashicorp.terraform",
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file"
  }
}
The formatOnSave block is optional but recommended — it runs terraform fmt on every save. One note: set formatOnSaveMode to "file" explicitly. The modifications and modificationsIfAvailable modes don't work with the Terraform formatter. 1
To share MCP Server config with a team, commit a .vscode/mcp.json to the repository:
{
  "servers": {
    "terraform": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "hashicorp/terraform-mcp-server:1.0.0"],
      "type": "stdio"
    }
  }
}

What to watch out for

Docker is non-negotiable for the MCP Server. The extension auto-detects Docker first, then Podman as a fallback. If neither is running, terraform.mcp.server.enable silently does nothing. 1
Large directories index slowly. GitHub Issue #1557 ("Performance Improvement Plan") has 37 reactions — the highest of any open issue in the repo. 6 Background indexing scans all .tf files and their module dependencies; opening a workspace with hundreds of nested modules will spike CPU and memory until indexing completes. One documented workaround: add your modules/ directory to the terraform-ls ignore list in settings. Code Lens (reference counts above blocks) also has a known performance cost on large projects, so disable it if you notice slowdowns. 1
tfenv users: pin your binaries. Several community reports flag format-on-save becoming unreliable when tfenv manages the Terraform version — the formatter intermittently loses its path to the terraform binary. 7 Pointing terraform.languageServer.terraform.path directly at a fixed binary path (rather than the tfenv shim) resolves the issue for most users.
OpenTofu is a separate extension. The HashiCorp extension targets HashiCorp Terraform only. If you've migrated to OpenTofu, use OpenTofu.vscode-opentofu (v0.6.2) instead — it ships its own tofu-ls language server and provides equivalent HCL features, though it has no HCP Terraform integration or MCP Server support. 8

Compatibility at a glance

Extension IDHashiCorp.terraform
Current versionv2.39.3 (2026-03-04)
VS Code minimumv1.86
Terraform CLI minimumv0.12
Bundled language serverterraform-ls v0.38.7 (2026-06-08)
MCP Server Docker imagehashicorp/terraform-mcp-server:1.0.0
MCP prerequisiteDocker or Podman (local, running)
LicenseMPL-2.0 (free)
Marketplace installs6,395,390
OpenVSXAvailable (Cursor / Windsurf compatible)

Add more perspectives or context around this Post.

  • Sign in to comment.