PyCharm
 
Get PyCharm

Terraform

Last modified: 23 January 2025

Terraform is an open-source tool that enables developers and operations teams to define, manage, and provision cloud resources and infrastructure components with code as opposed to manual configuration through a cloud provider's UI.

With it, you manage infrastructure resources, such as virtual machines, networks, and storage, in a declarative and automated manner. The replacement of manual configuration with codified templates ensures consistent and reproducible infrastructure setups.

PyCharm provides the following features:

  • Syntax highlighting

    You can customize color settings in the Settings dialog (CtrlAlt0S) , on the Editor | Color Scheme | HCL and Editor | Color Scheme | HashiCorp Interpolation Language pages.

  • Code formatting

    You can access code style settings related to Terraform in the Settings dialog (CtrlAlt0S) on the Editor | Code Style | Terraform page.

  • Full Line code completion

    Complete entire lines of code using a locally run deep learning model.

    https://resources.jetbrains.com/help/img/idea/2024.3/terraform_full_line_completion.png
    Gif

    You can disable Full-line code completion for Terraform in the Settings dialog (CtrlAlt0S) on the Editor | General | Inline Completion page.

  • The floating toolbar, which allows you to quickly comment and reformat code, as well as invoke context and AI actions.

    Terraform floatin toolbar
  • Inspections

    You can detect duplicate, conflicting, deprecated, or missing elements, unresolved references, unknown resources, and more.

    Terraform missing property inspection

    You can check all Terraform inspections in the Settings dialog (CtrlAlt0S) under Editor | Inspections | Terraform.

  • Code completion

    This includes completion for known providers, resources, data sources, and arguments.

    Terraform resource completion
  • Code navigation

    For resources, variables, locals, and data sources, PyCharm shows the number of their usages in the form of inlay hints. Click the inlay hint (or press Ctrl0B) to show all its usages and navigate to them.

    Terraform find usages

    You can disable, enable, and change the position of inlay hints for usages in the Settings dialog (CtrlAlt0S) under Editor | Inlay Hints | Code vision | Usages.

  • Refactorings

    To rename the element and all its usages, press ShiftF6.

  • Structure view

    Use the Structure tool window to quickly preview and navigate Terraform files.

    Terraform Structure

    The tool window is available in View | Tool Windows | Structure or by pressing Alt07.

  • Quick documentation

    Hover over an argument to get quick documentation for it.

    Terraform quick documentation

    For more details, you can also open Terraform Registry (which is the source of this documentation) by pressing ShiftF1.

    tip

    The Terraform and HCL plugin comes with provider metadata of a specific version (you can see the version number when you start typing a resource name). If your provider version differs, and you want to show relevant quick documentation for it, you may need to perform terraform init to retrieve documentation for that specific version.

Coding assistance also includes brace matching CtrlShift0M, code folding CtrlNumPad +/CtrlNumPad -, adding line comments Ctrl0/ and block comments CtrlShift0/.