terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Terraform fmt ignores tfvars

Open beanaroo opened this issue 7 years ago • 3 comments

Terraform Version

0.9.11

Expected Behavior

As per documentation:

rewrite Terraform configuration files to a canonical format and style.

Actual Behavior

Only tf files are formatted.

Steps to Reproduce

  1. terraform fmt -list=true -write=false ./dir
dir/main.tf
dir/variables.tf

Specifying the absolute path works for that file.

  1. terraform fmt -list=true -write=false ./dir/terraform.tfvars
dir/terraform.tfvars

beanaroo avatar Jul 21 '17 04:07 beanaroo

why is something so simple to fix not fixed yet?

luisdavim avatar Feb 24 '18 23:02 luisdavim

And also, why does terraform fmt place new lines in all tfvars ?

timm088 avatar Jun 29 '18 04:06 timm088

.tfvars files are not considered to be "part of the configuration" strictly speaking (they come from the command line), but I can see that in certain cases they behave as such and so it shouldn't hurt to format them if they happen to be in the same directory as the .tf files (which is not required, but common).

The configuration-language-related parts of Terraform are currently in a state of flux as we prepare for the next release, but we can investigate this once the dust has settled from that release and, in particular, terraform fmt will then be using the formatter from the new HCL version which should be better-behaved.

apparentlymart avatar Jul 03 '18 01:07 apparentlymart