Terraform: command/fmt: Quotes being added when fmt command run

Created on 17 Dec 2020  ยท  4Comments  ยท  Source: hashicorp/terraform

Not sure if this is actually a bug. It appears in 0.14.0 this issue #26390 added a more opinionated style of formatting quotes. From my understanding of it, quotes should be removed not added as a result of running the fmt command. Is my understanding correct or is the intended behavior to add quotes?

Terraform Version

Terraform v0.14.2

Terraform Configuration Files

resource null_resource a {

}

Expected Behavior

Nothing should change

Actual Behavior

Quotes are added to the resource and resource name. The above terraform becomes:

resource "null_resource" "a" {

}

Steps to Reproduce

  1. terraform fmt

References

  • #26390
bug new

Most helpful comment

I miss the cleaner formatting that was tolerated by v0.12 and v0.13 terraform fmt commands. I've gotten so accustomed to getting rid of all the "v0.11-style quotes" as a matter of code cleanup that this re-enforcement feels like a reversion.

Wish there was a way to vote for the cleaner style to be officially supported.

All 4 comments

Yes, this is expected behavior. From the PR:

Block labels are given in quotes.

Quotes are added, not removed, for labels, enforcing a consistent style that block labels (ex "null_resource" "foo") are quoted. As far as quotes being removed, you might be thinking of one of these other changes, which quieted deprecation warnings:

  • 0.11-style quoted variable type constraints will be replaced with their 0.12 syntax equivalents. For example, "string" becomes just string. (This change quiets a deprecation warning.)

  • Arguments whose expressions consist of a quoted string template with only a single interpolation sequence inside will be "unwrapped" to be the naked expression instead, which is functionally equivalent. For example, "${var.foo}" becomes just var.foo. (This change quiets a deprecation warning.)

Ok, thanks for clearing things up.

I miss the cleaner formatting that was tolerated by v0.12 and v0.13 terraform fmt commands. I've gotten so accustomed to getting rid of all the "v0.11-style quotes" as a matter of code cleanup that this re-enforcement feels like a reversion.

Wish there was a way to vote for the cleaner style to be officially supported.

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.

Was this page helpful?
0 / 5 - 0 ratings