rover
rover copied to clipboard
Plan files cannot be transferred between different Terraform versions
Hello,
I have an issue with terraform binary version used with rover (output bellow) It impose to use the exact same version as the one used to generate plan :/ It is very hard when time come to work with different plan sources (in team tf plan 4-eyes checking for example)
$ rover -planPath /plans/output.plan
2021/10/15 11:07:22 Starting Rover...
2021/10/15 11:07:22 Using provided plan...
2021/10/15 11:07:23 Unable to parse Plan: Unable to read Plan (/plans/output.plan): exit status 1
Error: Invalid plan file
Failed to read plan from plan file: plan file was created by Terraform
0.13.0-beta2, but this is 0.13.7; plan files cannot be transferred between
different Terraform versions.
Oh interesting, did you download rover locally on your machine? it defaults to using the same terraform binary you're using to generate your plan 🤔
Yeah I am using rover locally, but the plan file is from a pipeline, so a different terraform binary.
This is more a Terraform thing than a rover thing. Under the hood, rover runs a version of terraform show to parse the plan file.
The changes I've implemented in the tfc-integration branch kinda resolves this (c/p from https://github.com/im2nguyen/rover/issues/34#issuecomment-960423973). This new feature allows you to reference a plan JSON file, which makes it more robust. Rover can parse it, regardless of the current Terraform version you're running locally and in the pipeline.
I'm planning on cutting a release for this feature next week, but if it's urgent, you can build the binary from the tfc-integration branch.
Initial code on tfc-integration branch can take Terraform plan as a JSON, just need to implement pull from the Terraform Cloud API.
I tested it locally using go run . -planJSONPath=plan.json -tfConfigExists=false and verified it worked. To generate JSON configuration in local configuration, first, generate the planfile:
terraform plan -out=plan.out
then, write the planfile into a JSON:
terraform show -json plan.out > plan.json
Any word on this feature being released @im2nguyen ?