Terraform plan Write Out is Not Readable Text

Was reading the doc and tried several times to write out a plan to a file that is readable text. Looks like it’s writing out binary. I have been redirecting the output via the “>” operation. When redirecting output, the plan is readable.

When using terraform plan -out=new.plan, this shows portion of plan file:

I can use redirect but would like to get the option working.

Hi @phillip-burger-sculp,

The behavior you are seeing is as designed. The -out option is for creating a machine-readable representation of the plan that is only intended to be consumed by a subsequent Terraform command, like the terraform apply "new.plan" command line shown in the output.

Redirecting the output from Terraform to a file in the standard way is the easiest way to get that information into a file. A second option, if your concern is having the plan information in particular separated from the rest of the output, is to use the -out option as you used here to obtain the machine-readable file and then ask Terraform to re-render that plan, which you can then separately redirect to a file:

terraform show new.plan >plan.txt
1 Like