Loading...
Loading...
### Terraform Version ```shell Terraform v1.5.1 on linux_amd64 ``` ### Terraform Configuration Files ``` ``` ### Debug Output - ### Expected Behavior When using local state with custom `workspace_dir`, `terraform state rm` stores the state backup into the correct `workspace_dir` ### Actual Behavior `terraform state rm` tries and fails to save state backup into the default directory which does not exist. ``` 2023-06-23T23:38:39.169Z [TRACE] statemgr.Filesystem: creating backup snapshot at terraform.tfstate.d/workspace-a/terraform.tfstate.1687563517.backup Error saving the state: failed to create local state backup file: open terraform.tfstate.d/workspace-a/terraform.tfstate.1687563517.backup: no such file or directory The state was not saved. No items were removed from the persisted state. No backup was created since no modification occurred. Please resolve the issue above and try again. ``` `terraform.tfstate.d` does not exist because I have set `workspace_dir` to `.terraform-qa.tfstate.d`, so that is where state files reside. I can confirm this by looking at `.terraform-qa/terraform.tfstate` (I am also using a custom `TF_DATA_DIR` pointing to `.terraform-qa`) ``` { "version": 3, "serial": 1, "lineage": "336bd162-9070-27cc-079c-6884d4b3246f", "backend": { "type": "local", "config": { "path": null, "workspace_dir": "./terraform-qa.tfstate.d" }, "hash": 666019178 }, "modules": [ { "path": [ "root" ], "outputs": {}, "resources": {}, "depends_on": [] } ] } ``` ### Steps to Reproduce `terraform init` w/local state backend, custom backend config `workspace_dir` Attempt to `terraform state rm` something from the state. ### Additional Context _No response_ ### References _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.