`terraform fmt` borked when using terraspace templating

Hi there,

I’m loving the use of ERB templating within my terraform code to differentiate between environments. I’m supporting a bunch of legacy terraform code that needs to be re-written, but terraspace is severely helping me out with this.

Unfortunately, terraform fmt no longer functions because of course - the templating language used within terraspace is not producing valid HCL. Here’s an example block I’m using:

data "terraform_remote_state" "vpc-<%= expansion(':ENV-:REGION') %>" {
  backend = "remote"
  config = {
    organization = "my-org"
    workspaces = {
      name = "org-<%= expansion(':ENV-:REGION') %>-vpc-network"
    }
  }
}

Is there something you would recommend so that I can regain use of fmt?

Added

terraspace fmt

It’ll format all the source tf files in the app folder. So both app/modules and app/stacks.

  • Will skip files that contain ERB.
  • Only format files that have pure terraform code

For details see:

Released in terraspace v0.6.4 CLI Reference Docs: