I'm running the latest version of terraform. We have a huge directory of files that have never ran the fmt command. Had to run it a couple of times to format them all.
If this is expected behavior, should we output some sort of comment that it might need to be run again? Took me a bit to understand what was going on.
Terraform v0.11.13
Hi @heydonovan! Sorry for this strange behavior and thanks for reporting it.
Behind the scenes Terraform is relying on some Go standard library functions to enumerate the files in a directory, so I suspect that if such a limit exists it must be coming from those library functions. The relevant parts of the standard library are platform-specific, so could you let me know which operating system you're running Terraform on so that we can review the appropriate part of the Go standard library code?
Thanks!
@apparentlymart Sure! It's macOS Majove (10.14.3 (18D109)). However, I'm also using GitHub Actions to run the terraform fmt command on files we push to our repo:
https://www.terraform.io/docs/github-actions/getting-started/index.html
When we push, sometimes it runs into the same issue. Very interesting! 🤔
Thanks for that additional context, @heydonovan!
We're all focused on work for the forthcoming v0.12.0 release right now so I won't be able to investigate further immediately, but hopefully we can come back to this and figure out what's going on and fix it in a later release.
Terraform v0.12.0 actually has a rewritten version of terraform fmt as part of integrating the new configuration language engine, so we may find that this bug is already fixed or that the behavior in this situation has changed in some way as a result of that.
This _seems_ fixed in Terraform v0.12.x.
I created 336 tf files (https://github.com/veverkap/terraform_335) with a random provider in them with spacing off.
resource "random_string" "password314" {
length = 16
special = true
}
I then ran terraform fmt against them and it properly formatted all of the files (as you can see in https://github.com/veverkap/terraform_335/pull/1)
Hello! :robot:
This issue relates to an older version of Terraform that is no longer in active development, and because the area of Terraform it relates to has changed significantly since the issue was opened we suspect that the issue is either fixed or that the circumstances around it have changed enough that we'd need an updated issue report in order to reproduce and address it.
If you're still seeing this or a similar issue in the latest version of Terraform, please do feel free to open a new bug report! Please be sure to include all of the information requested in the template, even if it might seem redundant with the information already shared in _this_ issue, because the internal details relating to this problem are likely to be different in the current version of Terraform.
Thanks!
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
This _seems_ fixed in Terraform v0.12.x.
I created 336 tf files (https://github.com/veverkap/terraform_335) with a random provider in them with spacing off.
I then ran
terraform fmtagainst them and it properly formatted all of the files (as you can see in https://github.com/veverkap/terraform_335/pull/1)