dineshba / tf-summarize

A command-line utility to print the summary of the terraform plan
MIT License
534 stars 38 forks source link

add support for opentofu for binary plans #67

Closed quotidian-ennui closed 9 months ago

quotidian-ennui commented 9 months ago

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 |
+--------+----------+
+--------+----------+
kvendingoldo commented 7 months ago

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.