Problem
When executing a run in HCP Terraform or Terraform Enterprise, you may encounter a Failed handling run error similar to the following output.
[ERROR] terraform: Failed handling run: error="operation failed: failed writing remote backend config file: open /home/tfc-agent/.tfc-agent/component/terraform/runs/run-test.plan/config/projects/agents/zzz_backend_override.tf: no such file or directory"
Note: The zzz_backend_override.tf file is managed by HCP Terraform and Terraform Enterprise and is not expected to be present in your configuration.
Cause
This error occurs if the workspace is configured with a Terraform Working Directory that does not exist in the directory structure of the workspace's configuration.
You can find this setting in your workspace under Settings > General.
Solution
To resolve this issue, you must ensure the path specified in the Terraform Working Directory setting correctly corresponds to a directory within your configuration.
Verify that the directory exists in the configuration source for your workspace:
- For VCS-driven workspaces: Verify the directory path exists in your source repository.
-
For CLI-driven workspaces: Verify the directory exists in the local path from which you are running
terraformcommands. - For API-driven workspaces: Verify the directory exists within the uploaded configuration archive.