Terraform Cloud and variable management

i just got a snapshot from what apparentlymart wrote

  • Run terraform init locally against that configuration to configure the backend. That should reach out to the Terraform Cloud API and verify that the given organization exists and that your credentials grant access to it.
  • Run terraform workspace list to see the local workspaces that correspond to the remote workspaces you created in the first step. If you use the names I gave as examples, you’d see workspaces named stage and prod .
  • Return to the Terraform Cloud UI and configure the environment-specific variables for each of the networking- workspace using the variable management UI. (You can also manage these in Terraform using the tfe provider, but I won’t get into the details of that here for brevity.)
  • In your local shell, run terraform workspace select stage to select the staging workspace. You can run terraform apply here to push your current configuration up to the remote networking-stage workspace and run Terraform using the variables you configured for that specific workspace.
  • Similarly, run terraform workspace select prod to select the production workspace. Again, run terraform apply to push up the configuration and run Terraform with the separate workspace-specific variables for production.

from how-do-i-pass-var-file-on-teffaform-cloud
the terraform.tfvars file isn’t used in Terraform Cloud, because Terraform Cloud actually overwrites that file with the variables you configured in the web UI, in order to make those variable values available to the Terraform run.

If you rename that file to something ending in .auto.tfvars then it should work. For example, you could rename it to terraform.auto.tfvars . .auto.tfvars files take precedence over terraform.tfvars , which means that in the Terraform Cloud context values set in .auto.tfvars will override a value provided via the Variables web UI in Terraform Cloud (because Terraform Cloud writes those into terraform.tfvars ).