title: How to configure alignment and indentation of terraform code inside VS Code?
body: <p>I use VS Code to develop terraform code. My current plugin for terraform is:</p>
  
  <pre><code>Name: Terraform
  Id: hashicorp.terraform
  Description: Syntax highlighting, linting, formatting, and validation for Hashicorp's Terraform
  Version: 1.4.0
  Publisher: HashiCorp
  VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
  </code></pre>
  
  <p>Consider the following code:</p>
  
  <pre><code>output "sql_server" {
    description = "A dictionary of objects containing various Azure Sql Server properties per respective location."
    value = {
      for k, instance in azurerm_sql_server.instance : k =&gt;
      {
        resource_group_name = instance.resource_group_name
        fully_qualified_domain_name = instance.fully_qualified_domain_name 
        name = instance.name
        location = instance.location
        is_primary = instance.location == var.primary_location
        admin_login = instance.administrator_login
      }
    }
  }
  </code></pre>
  
  <p>I would like it to be reformatted like this when saving the file:</p>
  
  <pre><code>output "sql_server" {
      description = "A dictionary of objects containing various Azure Sql Server properties per respective location."
      value = {
          for k, instance in azurerm_sql_server.instance : k =&gt;
          {
              resource_group_name         = instance.resource_group_name
              fully_qualified_domain_name = instance.fully_qualified_domain_name 
              name                        = instance.name
              location                    = instance.location
              is_primary                  = instance.location == var.primary_location
              admin_login                 = instance.administrator_login
          }
      }
  }
  </code></pre>
  
  <p>Two things happen here:</p>
  
  <ul>
  <li>Indentation of 4 spaces was applied</li>
  <li>All the assignments within the same block were aligned</li>
  </ul>
  
  <p>There is a lot of information on the web on how to do it, but I am must be especially stupid for being unable to make it work, so I would like to get a very concrete answer containing the following details:</p>
  
  <ul>
  <li>What terraform plugin to use</li>
  <li>What exactly to write in my settings.json</li>
  </ul>
  
  <p>My current user settings.json file is:</p>
  
  <pre><code>{
      "workbench.startupEditor": "welcomePage",
      "editor.minimap.enabled": false,
      "terminal.integrated.scrollback": 1000,
      "git.enableSmartCommit": true,
      "editor.detectIndentation": false,
      "window.zoomLevel": -1,
      "diffEditor.renderSideBySide": false,
      "extensions.ignoreRecommendations": false,
      "workbench.colorTheme": "PowerShell ISE",
      "powershell.codeFormatting.whitespaceBeforeOpenBrace": false,
      "git.autofetch": true,
      "terminal.integrated.rendererType": "dom",
      "terraform.path": "C:\\Users\\mkharitonov\\.terraform\\terraform.exe"
  }
  </code></pre>
  
  <p>My local workspace settings.json file is:</p>
  
  <pre><code>{
      "git.ignoreLimitWarning": true,
      "powershell.codeFormatting.openBraceOnSameLine": false,
      "powershell.codeFormatting.whitespaceBeforeOpenBrace": false,
      "editor.formatOnPaste": true,
      "editor.formatOnSave": true
  }
  </code></pre>