dineshba/tf-summarize

add support for opentofu for binary plans

Closed this issue · 1 comments

At the moment trying to use tf-summarize with a binary plan that was generated by opentofu does not work.

It will raise the error (version refs will depend on your terraform version, latest opentofu version is 1.6.1)

bsh ❯ tf-summarize .tfplan
error when running 'terraform show -json .tfplan':
╷
│ Error: Couldn't show local plan
│
│ Plan read error: plan file was created by Terraform 1.6.1, but this is
│ 1.6.6; plan files cannot be transferred between different Terraform
│ versions
╵


Make sure you are running in terraform directory and terraform init is done

Workaround

Under the covers, tf-summarize just calls terraform show -json when presented with a binary plan; so just turn it into json via tofu.

bsh ❯ tofu plan -out .tfplan
bsh ❯ tofu show -json .tfplan >.tfplan.json
bsh ❯ tf-summarize .tfplan.json
+--------+----------+
| CHANGE | RESOURCE |
+--------+----------+
+--------+----------+

At this moment if you need to have a support of Terraform as well as OpenTofu (and Terragrunt :) ) in one tool you can use https://github.com/tofuutils/tenv which my team wrote some months ago. A lot of users switched to that tool to unify version management in the world of Terraform.

You're welcome to open any issues or contribute to tenv.