I'm using terraform on windows, and would like to visualize the graphs using Graphviz. However, there is a difference between the encoding that is being output by Terraform vs what Graphviz expects. Ideally, I want to do the following:
terraform graph -draw-cycles | dot -Tsvg > output.svg
That doesn't work, because the output that is being given by terraform is in the wrong encoding. The following sequence works, but uses an intermediate file:
terraform graph -draw-cycles > output.tmp
Get-Content .\output.tmp | Set-Content -Encoding Ascii output2.tmp
dot -Tsvg output2.tmp > output.svg
rm output.tmp
rm output2.tmp
However, I would like to do this without intermediate files using piping. A statement such as
terraform graph -draw-cycles | Set-Content -Encoding Ascii -PassThru | dot -Tsvg > output.svg
doesn't work. The output from the terraform graph statement is text, and apparantly the Set-Content commandlet needs additional information (Path?):
Set-Content : The input object cannot be bound because it did not contain the information required to bind all mandatory parameters: Path
At line:1 char:32
+ ... rm graph -draw-cycles | Set-Content -Encoding Ascii -PassThru | dot - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (digraph {:PSObject) [Set-Content], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectMissingMandatory,Microsoft.PowerShell.Commands.SetContentCommand
Any suggestions?