Updating Interpolation-only expressions are deprecated

Hi,
Finally getting around to upgrading my terraform (shame on me). Going from 11 --> 0.13.5 with a stop at 12 along the way. The upgrade went pretty smoothly but now I am getting the Interpolation-only expressions are deprecated warning.

I have about 300 instances of this and I have two questions:

  • Is there a recommended automated way to fix these issues (a.k.a. terraform fmt) ? I would like to avoid having to manually having to update 400 different spots in the code.
  • I assume that just removing the “${}” will still allow it to work as before? The var.varname will still resolve?

Thank you very much.

Warning: Interpolation-only expressions are deprecated

on modules/account/main.tf line 15, in resource “kubernetes_deployment” “account_domain”:
15: namespace = “${var.applicationNamespace}”

Terraform 0.11 and earlier required all non-constant expressions to be
provided via interpolation syntax, but this pattern is now deprecated. To
silence this warning, remove the “${ sequence from the start and the }”
sequence from the end of this expression, leaving just the inner expression.

Template interpolation syntax is still used to construct strings from
expressions when the template includes multiple interpolation sequences or a
mixture of literal strings and interpolations. This deprecation applies only
to templates that consist entirely of a single interpolation sequence.

(and 284 more similar warnings elsewhere)

Hi @mornindew,

The way this was intended to work out was for this to have been rewritten automatically for you by the Terraform v0.12 upgrade process, but it sounds like that wasn’t true in your case and now you are looking for a way to retroactively update these.

Terraform v0.13 has no automatic way to do it, but the forthcoming Terraform v0.14 (final release expected in the next week or so) will include a rule in its terraform fmt to automatically take care of some simpler cases that generate this warning, which would include the situation mentioned in the error message you shared.

With that said, your best bet might be to live with the warnings for a week or so and then upgrade to Terraform v0.14 and run terraform fmt. Another option would be to download the Terraform v0.14 release candidate and use it only to run terraform fmt; as long as you don’t run any other commands it will only rewrite your local configuration on disk.

Thanks a lot! Yeah, not sure why it didn’t happen. I followed the steps in the upgrade and everything seems to be working normally.

I can certainly live with the warnings for a while. Just a slight eyesore and nothing more.

Thanks for the insights.

Craig