I started with a large Terraform directory (root module) named old-name
that contained many Terraform config files, and a backend that also references the name old-name
. I want to refactor this by splitting it apart into a few independent directories (root modules) that manage related groups of resources. I want to preserve all the resources that old-name
manages, just move them to new Terraform config files and new root modules.
I’ve completed most of this; I’m at the point where all the config files have been moved, and the resources have been imported into their new state backends. I’ve used terraform state rm
to remove resources from the old-name
state. Running terraform state list
in old-name
shows no resources. If I just delete the directory containing the Terraform files, its state file remains, polluting the remote state storage, so I want to delete its state file as well.
To do this, I tried terraform workspace delete -force default
and received the error that I can’t delete the current workspace, and furthermore I’ve read that the default workspace cannot be deleted.
At this point, do I just have to delete the state file manually in the backend? Is there a best practice for fully deleting a Terraform project, almost like a “deinit” operation? Thanks!