question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

formatter does not the same as "terraform fmt"

See original GitHub issue

The formatter of the HCL plugin which is called on save does not the same as “terraform fmt”.

Prerequisites

  • Ensure you have latest version of plugin installed
  • Search for possible issue duplicates

Installation details

  • IDE version (Help->About->Copy to Clipboard) IntelliJ IDEA 2017.3.4 (Community Edition) Build #IC-173.4548.28, built on January 30, 2018 JRE: 1.8.0_152-release-1024-b11 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0
  • intellij-hcl plugin version (Settings->Plugins) Version: 0.6.9.4
  • Terraform version (terraform -v) 0.11.2

Terraform Configuration Files

# Copy-paste your Terraform configuration here - for large Terraform configs,
# please use a gist (https://gist.github.com) and share a link. 

Exception

Expected Behavior

What should have happened? If I do a terraform fmt on a file and afterwards press save in IntelliJ, nothing should happen (no re-formatting)

Actual Behavior

What actually happened? If I do a terraform fmt on a file and afterwards press save in IntelliJ, the HCL plugin removes whitespaces after the = in a variable assignment

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. write some tf file with variable assignments, e.g. ami = “${aws_ami.JenkinsAMI.id}”
  2. run terraform fmt which adds whitespaces , e.g. ami        = “${aws_ami.JenkinsAMI.id}”
  3. modify the file again to make it dirty and press save. The HCL formatter removes the whitespaces which where introduced by terraform fmt

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:50
  • Comments:22 (6 by maintainers)

github_iconTop GitHub Comments

30reactions
VladRassokhincommented, Apr 4, 2018

Unfortunately it’s impossible to match terraform fmt inside IDE, as HCL formatter depends on content and sometimes behaves quite strange and differently. I could recommend setting up File Watcher which would run terraform fmt after save. Could you also please change sample, as I don’t see difference.

21reactions
VladRassokhincommented, Jun 4, 2018

@cyberious AFAIR lining up = already works, just select on equals in Settings -> Editor -> Code Style -> Terraform Config -> Other -> Align properties Probably intention action should be added to navigate user to this setting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - formatter does not the same as "terraform fmt" -
The formatter of the HCL plugin which is called on save does not the same as "terraform fmt". Prerequisites. [ ] Ensure you...
Read more >
Using Terraform fmt Command to Format Your Terraform Code
The Terraform fmt command is used to format your configuration files into a canonical format and style. Learn how it can keep your...
Read more >
How to set up the same Terraform formatting style in VSCode ...
The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of ......
Read more >
Formatting Terraform Code With the Terraform fmt Command
A single misplaced bracket or an over-indentation can make your Terraform configuration files challenging to read, maintain, and understand — ...
Read more >
Command: fmt | Terraform - HashiCorp Developer
The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found