A quick note to myself on how to get terraform plan output as a file.
By default running a “terraform plan” will output a nice graphical display of all expected changes. Sometimes you want to be able to distribute this as a file. In the past, I’ve tried commands like:
terraform plan > tfplan.txt
However that produces confusing output like this:
Instead, you can do this to get better output:
terraform plan -no-color > tfplan.txt
Now it will display in the console, and produce a text file that looks like this:
11 thoughts to “Terraform plan output to file”
Thank you very much!
for me it is not working even using -no-color
What behavior do you see when using it? I was using this in Windows Terminal, perhaps it is different if you’re using a different shell?
try the tool terraform_landscape.
This is hard to install on Windows but easy for mac.
Otherwise, I try this:
terraform plan > color_output.txt
less -R color_output.txt
-R option prints colors
Thanks for this info!
Literally never commented on a blog before but this saved me a lot of time so thank you ?
What you’re seeing in those first outputs are ANSI color codes, themselves a subset of ANSI escape codes used to control terminal behaviour via in-band character streams.
The more you knooowwww