-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform fmt
adds extra lines in comment blocks
#6375
Comments
There's an issue and PR in the upstream parser for this: |
I ran into this issue as well, and I found a fairly simple workaround. For any multiline comments that are not attached to a resource (meaning there is an empty line between the comment and the resource), simply use the HCL syntax for a multiline comment instead of multiple single line comments. For example, instead of
do this instead:
As far as I can tell, the hcl printer is treating each standalone comment line as a separate comment, therefore they are separated by empty lines. I would still consider this a bug in hcl, but at least I can use |
This is fixed! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Affected Resource(s)
n/a
Terraform Configuration Files
Debug Output
https://gist.github.com/BrianHicks/45196caa7824eb6758ea071ecf2974b0
Expected Behavior
The comment block should have been left intact, as in the sample above.
Actual Behavior
Actual output:
All newlines included.
Steps to Reproduce
x.tf
terraform fmt x.tf
Important Factoids
Installed via homebrew
References
Couldn't find any.
The text was updated successfully, but these errors were encountered: