Terraform version: 0.11.3
The following diff describes layout before fmt and after fmt
diff --git a/nodegroup/01_variables.tf b/nodegroup/01_variables.tf
index 9dc7c01..d9a53f7 100644
--- a/nodegroup/01_variables.tf
+++ b/nodegroup/01_variables.tf
@@ -51,9 +51,7 @@ variable "node_policy_arns" {
}
variable "node_policy_arns_count" {
- // cannot be computed and has to be set manually
- // https://github.com/hashicorp/terraform/issues/12570
- // default = "0"
+ // cannot be computed and has to be set manually // https://github.com/hashicorp/terraform/issues/12570 // default = "0"
}
Thanks!
Seems like this occurs with # comments as well:
$ cat foo.tf
variable "example1" {
// comment 1
// comment 2
// comment 3
// default = "foo"
}
variable "example2" {
# comment 4
# comment 5
# comment 6
# default = "bar"
}
$ terraform fmt foo.tf
foo.tf
$ cat foo.tf
variable "example1" {
// comment 1 // comment 2 // comment 3 // default = "foo"
}
variable "example2" {
# comment 4 # comment 5 # comment 6 # default = "bar"
}
Hi @favoretti! Sorry for the weirdness here.
terraform fmt is about to get a big revamp as part of our work to integrate the new configuration language parser; this bug will probably get addressed as part of that work, so I'll leave this issue here for now as a reminder for us to test this case afterward.
@apparentlymart No worries, it's not a biggie, mildly annoying if anything :) Thanks!
Using 0.11.10.
Multi-line comments using /* */ block are also broken. If I have a comment like this:
/* Some text
More text
More text */
Running terraform fmt will give:
/* Some text
More text
More text */
Running it again will give:
/* Some text
More text
More text */
So it's not just that it's producing a weird output, it's also not idempotent. This makes automation of terraform fmt (e.g. in a Git hook) really annoying.
@jcmcken I just came across this too, I found a blank new line after the */ works around it if you need to.
With v0.11.13 CI/CD will never be happy again.
✗ terraform fmt
terraform.tf
✗ terraform fmt
terraform.tf
✗ terraform fmt
terraform.tf
Thanks everyone! This is fixed in terraform 0.12, so I will close this issue:
$ cat main.tf
variable "example1" {
// comment 1
// comment 2
// comment 3
// default = "foo"
}
variable "example2" {
# comment 4
# comment 5
# comment 6
# default = "bar"
}
$ terraform fmt main.tf
$ cat main.tf
variable "example1" {
// comment 1
// comment 2
// comment 3
// default = "foo"
}
variable "example2" {
# comment 4
# comment 5
# comment 6
# default = "bar"
}
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.
Most helpful comment
Using 0.11.10.
Multi-line comments using
/* */block are also broken. If I have a comment like this:Running
terraform fmtwill give:Running it again will give:
So it's not just that it's producing a weird output, it's also not idempotent. This makes automation of
terraform fmt(e.g. in a Git hook) really annoying.