HashiCorp maintains a Terraform extension for Visual Studio Code in order to ensure that practitioners have a first-class editor experience. Our extension has the unique opportunity to accompany you on every step of your journey, from learning the syntax and writing your first lines of HashiCorp Configuration Language (HCL), to provisioning infrastructure as part of larger teams at companies serving millions of users. Today we announce a public preview of an expansion of the capabilities of our VS Code extension, adding a native integration with Terraform Cloud in order to better support professional individuals and teams who rely on Terraform Cloud for standardizing and managing their infrastructure automation and lifecycle.
The new Terraform Cloud features are currently available in the pre-release version of our Terraform extension, which is the Visual Studio Code equivalent of a public beta channel. If you want to opt-in to receiving the new version in order to check out these capabilities before we roll them out to all users:
- Bring up the Extensions view in Visual Studio Code (Ctrl+Shift+X or ⇧⌘X)
- Search for the HashiCorp Terraform extension
- Click on “Switch to Pre-Release Version”
If the text on the button says “Switch to Release Version”, it means the pre-release version is already installed.
The extension does not currently have a native login interface for Terraform Cloud and instead relies on you to supply a Terraform Cloud API token with user-level permissions. If you’re already using the Terraform CLI with Terraform Cloud, select the “Stored User Token” option in the login prompt to have VS Code use the same token you supplied to the CLI.
The other two options require you to manually supply a token. If you don’t already have one, you can easily generate one in the Terraform Cloud web interface on the User Tokens page:
You then need to supply this token to the extension as follows:
You can confirm it’s working properly by verifying that the new Terraform Cloud view allows you to pick an organization and then display all the workspaces under that organization that you have access to:
The core capabilities of the new Terraform Cloud integration in our Visual Studio Code extension focus on providing a read-only view of workspaces and runs in order to reduce the amount of window- and context-switching you need to do. Instead of opening up the Terraform Cloud web interface in your browser to look up why a run failed and then switching back to VS Code to look for the configuration that caused the error, you can now view the apply log side-by-side with your code, allowing you to get back to debugging faster.
You can also hover over each run to see more information, such as which user initiated it, when, and what the outcome was, which is especially helpful when you’re collaborating on one workspace with a team:
To see the full list of features as we continue to add to them over the coming months, check out our documentation.
The operating principle behind this initiative has been to move quickly and keep the featureset intentionally lean at the outset in order to provide a public preview for users faster, get feedback, and continue to iterate. The sky is the limit in terms of the Terraform Cloud features we theoretically could integrate into the VS Code extension, and your ideas and suggestions are crucial in helping us decide what to prioritize building next.
Since this is an open source project, please request new features, report bugs, or suggest improvements to our documentation in GitHub. For questions and general discussion, this HashiCorp Discuss forum is a great place to start. We’d especially like to hear whether you find the interface intuitive and how well it’s working for your use case, such as a setup with hundreds of workspaces or whether you’re using the VCS integration with Terraform Cloud.