tofu-controller
tofu-controller copied to clipboard
Improve backend semantics
controller docs state that:
By default, TF-Controller uses the Kubernetes backend to store the Terraform state file (tfstate) in clusters.
Curretnly there is no way of using an existing backend block that is already defined in tf code
terraform {
backend "some backend" {
...
...
}
}
will be ignored, or overrider when using backendConfig
There is an option to set
backendConfig:
disable: true
but as discussed https://github.com/flux-iac/tofu-controller/issues/389#issuecomment-1988280696 this only applies to Terraform Cloud and not for private custom backends, and will result the runner to backend seems to be disabled completely, so there will be no plan output file
later while using the branch planner there will be endless commits to git, since the planner fails with
"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 is a result from here
// if backend is disabled completely, there will be no plan output file (req.Out = "")
if r.backendCompletelyDisable(terraform) {
planRequest.Out = ""
}
Opened the issue to improve backend semantics in backlog, motivation here is to have a single source of truth for the backend definition, both for a human executing terraform, and the automated controller.