terraform

Announcing the Terraform Visual Studio Code Extension v2.0.0

As previously announced, we recently took over support for the Visual Studio Code (VS Code) extension for Terraform by Mikael Olenfalk and open sourced a Terraform Language Server. The VS Code extension is one of the most popular editor extensions for Terraform, with over 600,000 installs from in the Visual Studio Marketplace.

Both of these projects together allow us to start providing editor support for syntax highlighting, code completion, and other features for Terraform users. As part of this initiative, we are excited to announce the first HashiCorp release for the Visual Studio Code extension. There are two main features in this release:

  • Usage of the HashiCorp Terraform Language Server
  • Terraform 0.12 syntax support

» HashiCorp Terraform Language Server

Much of the functionality people would identify as improving the editor support for a language can now be added through the implementation of a language server. Writing a language server for these features, instead of providing them directly in an editor extension, allows us to leverage existing packages and features, coded primarily in Go for Terraform, in a binary that can be reused by multiple different editors (there are instructions for Sublime Text, VIM, Emacs, and others in the repository).

In our initial release we are focusing on implementing code completion functionality for data source, resource, and attribute information. Over time though, we plan to add expression completion support, module completion support, and many other features. If there is a specific feature you have in mind, and it's already on our list of issues, please add your use case or add a reaction to show your support. If one does not exist, please file a new one. We are looking for feedback on what features are most important to the users of the extension, and this is one of the signals we will be using for prioritization.

If you want to know more about the Language Server Protocol or our implementation, you can read more in our previous announcement or on the Terraform language server repository.

» Code Completion

The main feature added via the Terraform Language Server is code completion. The language server interacts with Terraform via the CLI which is a universal enough interface to work across different Terraform versions. It uses schema information output from providers obtained via the terraform providers schema -json command. This command outputs the schema of all initialized providers in your project. Documentation information can be published as part of the provider binary and this will be used by the Language Server when serving completion items and in any other interactions that will be implemented in the future (e.g. when hovering over a piece of code).

After running a terraform init in your project, schema information for can be completed for custom, internal, or community providers like the community provider for Unifi (shown here being used to manage a WiFi SSID):

Schema information is also available for autocompletion in our official providers for AWS, Google, and Azure as well:

Over time we hope to keep enhancing both the documentation surfaced in our official providers as well as the information shown and completed through the language server.

» Terraform 0.12 Support

In this version, we've also updated the syntax highlighting to work under Terraform 0.12. Errors that were seen in trying to read 0.12 files have also been eliminated. Highlighting and other core features will be partially compatible under 0.11 as well but continuing development will only focus on 0.12 and future versions. If you work in 0.11, you should pin your extension to an earlier version. Future versions of the language server will reintroduce diagnostic information to the editor such as syntax errors and validation errors.

» Just the Beginning

Version 2.0.0 is just the beginning of our support for VS Code and editor integrations in general. We have a dedicated team and roadmap focused on both the extension and language server. Both projects are open source and we welcome community feedback, bug reports, and feature requests in each repository.

This release creates a strong foundation we can continue to build upon. We invite you to give the new Terraform extension a try!


Sign up for the latest HashiCorp news