Handling Input Variables in different Workspaces

I will preface my questions with I am fairly new to Terraform and Terraform Cloud. My question is similar to this what is being talked about in this thread: How do i pass -var-file on Teffaform cloud - #5 by umashankar2

I have a Terraform Cloud workspace for my Dev/Tst environment. When I started with this workspace I knew I was going to build it so that I could use the same Terraform project for both my Dev/Tst environment and Uat/Prod environment. The main.tf and all modules are built to run based on input variables. I am currently using multiple auto.tfvars files as a way to cleanly define values for the input variables for each type of resource. The variables defined in the auto.tfvars files are of type list(object()) and (sometimes 2000+ lines) long. My use of auto.tfvars files it’s not going to be conducive to multiple environments because the contents of the files would be different in Dev/Tst than they would be in UAT/Prod. I am trying to figure out how I can supply values to these input variables based on environment given the fact that there are multiple variables and extremely long.

Some of the solutions discussed no longer work as they did last year due to updates within Terraform Cloud. For example, it’s now suggested to use the “cloud” block instead of the “backend” block within the terraform config block. I implemented the “cloud” block when I migrated my state to Terraform cloud. The “backend” block supported prefixes which I thought would be an option but the “cloud” block doesn’t use prefixes. It seems like tags in “cloud” blocks might be the replacement for prefixes in the “backend” block but I’m not real sure since there isn’t real good info or examples of how this is used for my scenario.

Does anyone have any suggestions how this might be done?

P.S. I don’t believe this matters much but I am using the chanzuckerberg/snowflake provider to manage Snowflake accounts and not the typical providers around AWS, Azure, etc.

I have made some head way on this. I found that I can switch the auto.tfvars files to tfvars files and then reference them in TF Cloud by setting the TF_CLI_ARGS environment variable.

I found that in TF Cloud if you want to use specific TFVARS files you will need to include the TF_CLI_ARGS environment variable. The other thing that isn’t well documented is the format in which the values need to be. So the Key would be TF_CLI_ARGS and the value would be something like: -var-file=“variable_values.tfvars”. The equals and double quotes are important. If you don’t have those, it doesn’t work and doesn’t give you good information on how to fix it.

As far as I can tell, the tags in workspaces is the replacement for prefixes in the old backend block but I haven’t made much headway on that yet.