tofu-controller icon indicating copy to clipboard operation
tofu-controller copied to clipboard

No plan output using Terraform Cloud 'local' execution mode

Open tao-zhang-shell opened this issue 2 years ago • 6 comments
trafficstars

I use Terraform Cloud only to store TF backend state files, still use TF controller to plan and apply Terraform changes.

Screenshot 2023-09-14 at 20 11 26

When I deploy a Terraform CR, manual approval is configured so that I can confirm the plan. It looks good that Terraform CR is created successfully and plan ID is also provided. But if I check the plan output which is created as a Kubernetes secret, there is no actual plan. I base64 decoded this secret and unzip it, the contents of this file is dummy plan.

Meanwhile, the runner pod logs this:

Screenshot 2023-09-14 at 20 18 30

You can see the Terraform Cloud backend is correctly initiated, it seems that TF controller didn't run terraform plan at all.

For another test, I enabled storeReadablePlan: human in Terraform CR. Then it failed to create the Terraform CR. The runner log gives the error:

{"level":"error","ts":"2023-09-14T14:33:10.849Z","logger":"runner.terraform","msg":"unable to get the plan output for json","instance-id":"cd68b59d-ebe6-4b61-90ce-1793ab33cb6a","error":"\nError: Failed to read the given file as a state or plan file\n\nState read error: Error loading statefile: open tfplan: no such file or\ndirectory\n\nPlan read error: open tfplan: no such file or directory\n"}

This makes me believe there was no plan generated at all.

Can you please check this? If this is a bug, can you please fix it? Thanks!

tao-zhang-shell avatar Sep 14 '23 18:09 tao-zhang-shell

Sorry but we support only the "Remote" Execution Mode for Terraform Cloud at the moment.

But we support the mix mode by using Remote execution mode with spec.approvePlan: auto together wtih the Branch Planner. With Branch Planner + Terraform Cloud, you will get the same manual concept similar to the manual approve workflow.

chanwit avatar Sep 14 '23 18:09 chanwit

We'll have a tutorial on this very soon after ironing out the new RC.

chanwit avatar Sep 14 '23 18:09 chanwit

@tao-zhang-shell in the mean time, please try this doc: https://weaveworks.github.io/tf-controller/branch_planner/tfc-integration/

chanwit avatar Sep 14 '23 18:09 chanwit

@chanwit Thank you for the information. Unfortunately, I want the TFC Local execution mode, not just manual approval. Do you have any plan to support TFC Local execution mode?

tao-zhang-shell avatar Sep 15 '23 07:09 tao-zhang-shell

Yep, we planned to support it and other Terraform Cloud feature, but our priority now is the Branch Planner system.

chanwit avatar Sep 15 '23 07:09 chanwit

hello @chanwit - Do you have an update on the plan to use Terraform cloud with Local option?

amchau avatar May 15 '25 10:05 amchau