Currently at my company we use Terraform Open Source quite succesfully to manage all our Production builds. We use a workspace approach to separate out our environments and that works great.
Recently though I’ve been looking into Terraform Cloud as the sentinel side of things will work really well for us. I did notice that you create workspaces within the cloud environment but they do not translate into the state. How would we manage our code base using the terraform.workspace within terraform cloud?
Hope this makes sense, look forward to hearing from you.
Using the remote backend, the terraform.workspace expression indeed must be removed and is not supported in Terraform Cloud. You can read about that here.
Stay tuned though, as there will be a solution for this usage specifically very soon! The new native integration for Terraform Cloud in Terraform 1.1 will align workspace names between CLI and Terraform Cloud, so terraform.workspace will indeed work as expected.
However, even without terraform.workspace specifically, you can achieve the same effect for things like usage in Sentinel policies. For Sentinel specifically, there’s a special tfrun import which allows you to write policy with the TFC workspace name for that run - I’d probably use this mechanism over terraform.workspace anyway, to be honest. The workspace name is also available in TFC’s run environment.