Am I missing something or Terrafrom Cloud is not fully ready for more complex variable management ( maps, list, lists of maps etc).
So far we have been running terraform via Command Line and it works well. But we want to go to Terrafrom Cloud and get all the benefits there. However it seems something is not fully ready there or I do not understand it
If we have some Repository with Terrafrom Code and mapped that repository to TF Cloud Workspace.
We have variables in that repository (not sensitive variables) like …AMI ID, users …etc. Those variables sometime can be complex - map, lists, maps of lists etc.
We want to keep managing those varibles via GIT to see who commited what and changed etc.
We do not want to MANUALLY change variables via the TF Cloud UI. It is not easy to track what changes have been made there.
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.
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 ).