Terraform plan output: what is the encoding being used
The Terraform plan output is a binary format that is not designed to be used outside of Terraform. Technically you could probably serialise it using whatever Terraform uses to handle the format but there is no stable API for this and could change at any point.
One of the Hashicorp employees (Phinze) briefly covered this in this issue: https://github.com/hashicorp/terraform/issues/7976
One, probably reasonably fragile, option would be to simply parse the text output from running terraform plan
. I use Terraform Landscape to format plan outputs locally when working with JSON diffs that Terraform doesn't handle at all and that copes with this fine. However it also tends to break on the "minor" version upgrades (eg 0.9 to 0.10) as Terraform doesn't specify this as an API at all. Terraform Plan Parser also parses the textual output and notes that it is very much not to be used with the binary output.
While the other tools mentioned here are useful, things change regularly in the Terraform space and third-party tools often aren't able to be kept up-to-date.
For some time now Terraform has directly supported viewing a plan file in the same human-readable format that is displayed at the time you run plan
:
terraform show <filename>
Since v0.12 you can now also view a plan file in JSON format, which you could save to work on further with other tools:
terraform show -json <filename>
There's an explanation of the JSON schema at https://www.terraform.io/docs/internals/json-format.html. As of writing, note that:
The output ... currently has major version zero to indicate that the format is experimental and subject to change. A future version will assign a non-zero major version ... We do not anticipate any significant breaking changes to the format before its first major version, however.