0
votes

According to this:

https://www.hashicorp.com/blog/terraform-0-12-template-syntax

Terraform is extending interpolation syntax used for strings (${}) to loops and conditionals (which implies interpolation syntax is still valid for strings).

However, if I run terraform 0.12upgrade on my .tf scripts, it changes syntax in my Outputs file from:

output "OutputName" {
    value = "${module.module_name.resource_name}"
}

to this:

output "OutputName" {
    value = module.module_name.resource_name
}

Why is it re-writing my interpolation syntax?

2

2 Answers

0
votes

You are correct that interpolation syntax is still valid in Terraform 0.12. However, it is now unnecessary unless you are trying to combine multiple values together into a string, so the upgrade tool is automatically rewriting to use the simplest way to express the same idea.

If you want to retain the interpolation markers for some reason then you can ignore that change made by terraform 0.12upgrade and retain your existing configuration as-is. However, I'd recommend accepting the change because the extra quotes and interpolation markup doesn't add any additional information or change any behavior, and is therefore entirely redundant.

0
votes

This is because it is updating your code to be more HCL2 compliant. In this case, you are referring to a value within your configuration and this can be achieved by using a HCL2 Expression. Therefore, the upgrade tool is replacing the old interpolation by a HCL2 Expression.

You can find more information about HCL2 Expression on this link:

https://www.terraform.io/docs/configuration/expressions.html