Today I Learnt FM
On , I learnt ...
Terraform can automatically dedent multiline strings

You can use heredoc markers to define strings in HCL that span multiple lines. There is also a way to automatically strip out all extra indentation that may have in it, by using the <<- operator.

To test this, you can create in an empty dir a main.tf file with these contents:


output "heredoc-raw" {
  value = <<EOT
      this
        is
          indented
  EOT
}

output "heredoc-indented" {
  value = <<-EOT
      this
        is
          indented
  EOT
}

and then run these commands to get the outputs:


> terraform apply
...
> terraform output -raw heredoc-indented
this
  is
    indented
> terraform output -raw heredoc-raw
      this
        is
          indented

This helps when you want to keep your code nicely indented, regardless of whether a specific line is an instruction or data.