-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remote
backend fails in un-initted working directory with prefixed workspaces
#21224
Comments
@mildwonkey, I think you're taking over the maintenance of the backend, right? @tr0njavolta, just pinging to make sure you get future notifications on this issue while I'm out. |
Given how this was resolved in the 0.11 case (by selecting a workspace and then re-running The solution to this may also interact with #21133, which would include fetching all of the workspace names from the backend as part of |
HEY, that totally works, on both 0.11.13 and 0.12 beta! You just have to make sure the workspace name you choose actually exists (and that you don't have a dumb typo in your backend config after testing twelve different things).
@apparentlymart Good guess! |
There is actually already logic for this use case, but that logic was only called during a specific migration scenario. I reshuffled the logic a bit so its now always called after creating a backend from config to make sure it will always perform this check. This results in the following UX, which is exactly what we want (AFAIK): I'll make a PR for the changes in a bit and will link them to this issue. |
Those ^^ two PR fix this issue for both v0.11.x and v0.12.x. |
sweet, thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Steps to Reproduce
First, act as the "primary user."
remote
backend to use multiple workspaces, using theprefix
argument, as show above.appserver-prod
,appserver-dev
, etc.)Next, act as the "new collaborator/teammate." You have not used this Terraform configuration before, and are trying to get up and running for the first time. Ideally, you'll be able to just jump in and start using your team's shared state.
.terraform
directory or any state or anything. Pristine.terraform init
.Expected Behavior
Terraform sees that there's no prior state to reconcile, and sets up workspaces according to the configured prefix. You end up with several workspaces with short local names like
prod
,dev
, etc., and can switch to one of your choosing and start editing the config and running plans. These workspaces use the remote workspaces' state according to the prefix mapping.Since you didn't have prior state and hadn't previously selected a workspace, you don't have an expected initial workspace. Maybe it's the first alphabetical one, maybe it's random, who knows. (I'd expect init to tell me which workspace it picked, and I'd also expect that there's a low chance it's the one I wanted and I'll need to switch anyway.)
Actual Behavior
Terraform 0.11.13
I guess I need to select a workspace?
It looks like init got far enough to give me a workspace list, but not far enough to download plugins or anything. OK!
At this point things work, but that was kind of unpleasant.
Terraform 0.12 beta 2
Guess I need to list workspaces and choose one.
Oh..... that won't even work. So, now what? I guess I comment out the backend, run terraform init, uncomment the backend, init again, choose a bogus name for the default workspace, and then delete the unwanted default workspace after everything's up and running?
Additional Context
name
argument. It's just the multi-workspace setup that's hosed.default
unnamed workspace being forbidden with prefixed workspaces. (This isn't a workspace nameddefault
, I think, it's the way the workspace code chooses to display the unnamed state file that isn't in the state.d directory.) Except the new teammate doesn't actually have that workspace; they don't have anything.default
workspace, init asks you to give it a new name while it's setting up the remote backend.The text was updated successfully, but these errors were encountered: