Skip to content

Instantly share code, notes, and snippets.

@mbaitelman
Created July 9, 2020 05:49
Show Gist options
  • Save mbaitelman/3a2b15d7bb8c0b109c40d94892bbca52 to your computer and use it in GitHub Desktop.
Save mbaitelman/3a2b15d7bb8c0b109c40d94892bbca52 to your computer and use it in GitHub Desktop.
Fixing "Warning: Interpolation-only expressions are deprecated" with Powershell

In terraform .12 they changed how expressions are allowed to be interpolated and removed the need for quotes. So "${var.variable}" can now be var.variable.

Here is a powershell script that will loop through your Terraform code and update those expressions.

forEach($file in gci -Recurse -Filter *.tf -file){
Write-host "updating " $file.Fullname -ForegroundColor Magenta
((Get-Content -path $file.Fullname ) -replace '^(.*)\"\${(.*)}"','$1$2') | Set-Content -Path $file.Fullname
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment