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 namedstage
andprod
. - 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 thetfe
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 runterraform apply
here to push your current configuration up to the remotenetworking-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, runterraform 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
theterraform.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 toterraform.auto.tfvars
..auto.tfvars
files take precedence overterraform.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 intoterraform.tfvars
).