I am trying to do “terraform workspace new -state=statefile.json test” and instead of creating a workspace using the state from statefile.json, it is creating an empty state workspace. Am I using that functionality wrong?
Hi @brantgurga,
The -state
and various similar options are legacy vestiages of the local backend which we’ve preserved only enough to avoid breaking some historical workflows that predate the concept of state backends.
I think the best way to create a new workspace populated from an existing state file, in a way that works across all backends and without relying on a legacy option, would be the following two-step process:
terraform workspace new test
terraform state push statefile.json
I can see that we missed terraform workspace new
when we were updating the command docs to split those legacy options out to the local
backend documentation, so I’ve opened an issue to prompt us to review the other command pages for similar inconsistencies.
Thanks!
1 Like