I use tfswitch to use different terraform versions. And I am trying this in my VSCode
When running terraform fmt --recursive none of my terraform files are actually getting formatted.
For example, some code in terraform version v0.11
environment = "${var.environment}"
project_name = "${var.project_name}"
running a terraform fmt with version 0.12 should change this to:
environment = var.environment
project_name = var.project_name
But nothing happens when i run it.
I have to get other people to checkout my code and run it for me which isn't ideal in the long run.
Is this an issue with tfswitch, or something wrong with my terraform? It used to work and only started noticing this problem a couple weeks ago and not sure what has changed since then. I tried reinstalling tfswitch to see if that fixed anything but no luck
The auto-correction of HCL1 to HCL2 based DSL for Terraform with
terraform fmt
was implemented in 0.14. Therefore, you will not see those changes with your Terraform 0.12.I have tested with 0.12, 0.13, and 0.14 to verify, but more to the point we see in the CHANGELOG this was introduced in 0.14.0. Note the item:
Note also the associated PR implementing this for 0.14. If "other people" are observing this behavior with
terraform fmt
, then they are using Terraform 0.14 or later.