formatter does not the same as "terraform fmt"
See original GitHub issueThe 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:
- write some tf file with variable assignments, e.g. ami = “${aws_ami.JenkinsAMI.id}”
- run
terraform fmt
which adds whitespaces , e.g. ami = “${aws_ami.JenkinsAMI.id}” - 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:
- Created 6 years ago
- Reactions:50
- Comments:22 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 runterraform fmt
after save. Could you also please change sample, as I don’t see difference.@cyberious AFAIR lining up
=
already works, just selecton equals
inSettings -> Editor -> Code Style -> Terraform Config -> Other -> Align properties
Probably intention action should be added to navigate user to this setting.