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.