I have plan files generated with different terraform 0.12 versions. For my processing I just want to see the json output of these files. I am using terraform 0.12.17 version to run the command “terraform show -json planfile” on those plan files one by one. But I am getting this error:
Error: Invalid plan file
Failed to read plan from plan file: plan file was created by Terraform 0.12.6,
but this is 0.12.17; plan files cannot be transferred between different
Terraform versions.
I understand that Terraform does require the same version and plugins being available to use the terraform command on the existing plan files. But this is just the show file for converting to json. Is there a way so that “terraform show -json” be version agnostic, atleast for subversions within the major version i.e. terraform v0.12.
Hi @ngarg-panw,
We don’t have any plans to make the binary plan file format stable for the moment, because we are still regularly changing Terraform’s internals for features like module for_each
, etc and the plan file is essentially just a serialization of internal data structures within Terraform at the moment. That may change in the far future, but not in the near future.
In the meantime, I’d recommend that if you are intending to save plan files for archival purposes you should immediately generate the JSON form with the same terraform
executable that produced the plan and save the JSON form as the archival form. Although at this time the JSON plan format is still subject to change, in practice it changes far less frequently than the binary plan output because it doesn’t need to capture the same level of detail as Terraform requires to run terraform apply
with a saved plan. The binary plan format is not intended for long-term storage, and is instead expected to be discarded as soon as the plan has been applied.
The above strategy is, for example, how Terraform Cloud approaches the problem: immediately after generating a saved plan, it runs terraform show -json
and saves the result for use by future operations such as Sentinel policy enforcement, cost estimation, and any other plan-derived features Terraform Cloud might grow to include in future.
1 Like
Thank you. This is helpful for us to make certain considerations.