I’m experimenting with the “terraform remote”, aka “terraform enterprise” remote. I previously have had remote state in s3. A repo might look like this:
myrepo/
project_a/main.yml
project_b/main.yml
In that case, the “key” param of the s3 backend might be “project_a” and “project_b”. Some interpolation is required when pulling the terraform_remote_state to interpolate with workspaces.
Moving to the “remote” remote means there’s a name (no workspace support) or a prefix. I thought that I should use a prefix of myrepo- but it seems to stomp on the subdirs. Should I be using a prefix of myrepo-project_a- and so on? I just can’t tell if that’s the best practice.
Yes, I believe your mapping of S3 key and prefix to workspace names is the correct pattern since workspaces are not prefixed / subdirectories in Terraform Cloud (AKA enterprise free tier).
Ah! I think I am misunderstanding your question, my apologies.
Just to clarify, what of the below are you looking to migrate?
TF Enterprise remote state in S3 to TF Enterprise remote state managed?
TF Enterprise remote state in S3 to TF Cloud?
TF open source remote state in S3 to TF Cloud?
If you’re using Terraform Cloud (free tier), it currently does not support interpolation of workspaces. We need to explicitly state the prefix and workspace as the name:
Thanks. I’m doing option 3 (so far), it looks like my combination of project+subproject is on the right path. It does look, however, like I can use prefix and the workspace is implicitly added- obviously I can’t do actual interpolation in the .tf, but it gets added: