DEV Community

Cover image for Reuse tfvars in Powershell
Antoine
Antoine

Posted on

Reuse tfvars in Powershell

Photo by Thought Catalog on Unsplash

To reuse data in Powershell set in tfvars, we just have to use the ConvertFrom-StringData cmdlet.

In order to remove some character (such as { or } ), we can use -replace .

That will give us

$file = Get-Content .\varfile.tfvars
$file = $file -replace "}", ""
$file = $file -replace "{", ""
$convert = $file | ConvertFrom-StringData
Enter fullscreen mode Exit fullscreen mode

Hope this help !

Discussion (0)