Adds syntax highlighting and other editing features for Terraform files
Features at a glance
- Auto-completion support
Terraform high level types
(variable, resource, data, module ...) auto completion support.
(aws_dynamodb_table ...) auto completion support for
resource | data | module | output | variable property types auto completion support
resource | data 1-level nested block property types auto completion support
- Syntax highlighting for
.tfvars files (and
- Automatic formatting using
- Automatically closes braces and quotes
- Adds a command for running
- Linting support with the help of tflint
- Browse document symbols
- Browse workspace symbols
- Peek definition
- Goto definition
- Find references
- Completion for variables and outputs
- Rename variables, resource, and data types and all references
- Show variable values on hover
- CodeLens shows if a section is referenced
News in 1.0.0
- Indexing support is no longer experimental
- Indexing support no longer requires a separate tool (HCL parsing is now built directly into the plugin)
- Rename refactoring now supports all types
- Hovering a variable shows the default value
- A code lens shows how often a resource (or variable, or data) is referenced
- Terraform now works with Visual Studio LiveShare (thanks to @lostintangent)
The plugin also ships a formatter integration which uses
terraform fmt for
formatting files. Formatting can be enabled or disabled by setting
You can lint your terraform templates by invoking the command
Terraform: Lint from within VSCode.
Linting is supported with the help of tflint, either download it and add it
to your path or can configure
terraform.lintPath to point to your tflint executable.
tflint will be executed
with the workspace directory as the current working directory so you can configure
tflint by dropping a
file in your workspace root.
You can change the configuration file path by supplying the configuration option
terraform validate your project by invoking the command
Terraform: Validate from within VSCode.
terraform validate is invoked with the workspace root as current working directory and with the setting
terraform.templateDirectory as template directory, by default this setting is "templates" (relative to
Because the output of
terraform validate is not parseable the output is just dumped into the output tab.
The plugin indexes all the terraform files in the workspace by default and enables some advanced features,
like Goto Definition and Show references based on information gathered during indexing.
Indexing is enabled by default but can be disabled using
Browse Document Symbols
⇧⌘O to browse symbols in the current file.
Browse Workspace Symbols
⌘T to quickly jump to any symbol.
Peek and Go To definition
⌥F12 to peek definition (currently only some types supported).
Find All References
⇧F12 to find all references (currently only variables).
Ctrl+Space (also triggered automatically after
") for simple code completion (currently only variables and outputs).
Rename variables, resources and its references
F2 to automatically rename a variable and its usages.
Show variable default on hover
Document Link support
Outline View support