idoavrah / terraform-tui

Terraform textual UI
https://pypi.org/project/tftui/
Apache License 2.0
1.03k stars 30 forks source link

Support Tofu backends with variables #85

Open sarg3nt opened 2 months ago

sarg3nt commented 2 months ago

OpenTofu v1.8.0 supports early variable/locals evaluation which allows for variables in backends. These do not appear to work in tftui.

Here are the commands I've tried.

tftui -e tofu -f ../deployments/k8s-common-dev.tfvars -f ../deployments/k8s-dev.tfvars
# and
tftui -e tofu -n -f ../deployments/k8s-common-dev.tfvars -f ../deployments/k8s-dev.tfvars   

And the error output

Error: Unable to compute static value

  on backend.tf line 4, in terraform:
   4:   backend "remote" {

backend.remote depends on var.tofu_backend which is not available

Config of the backend

terraform {
  backend "remote" {
    hostname     = var.tofu_backend.hostname
    organization = var.tofu_backend.organization
    token        = var.tofu_backend.token
    workspaces {
      prefix = "cluster_"
    }
  }
}

Are there any plans to support Tofu and backends with vars?

sarg3nt commented 2 months ago

What you might need to do to fix it is pass the vars to every command. i.e. they are needed in tf init, tf show, tf state * etc. We had to rework some of our automation to get it all to work.