Search code examples
terraformterraform-cloudterraform-remote-state

Terraform Cloud failed writing remote backend config file - error: zzz_backend_override.tf: permission denied


Error message received by running plan or apply command on Terraform Cloud with remote cloud execution:

Operation failed: failed writing remote backend config file: open /home/tfc-agent/.tfc-agent/component/terraform/runs/runId/config/infra/zzz_backend_override.tf: permission denied

If I change to local execution (runs on my local dev machine and not Terraform infrastructure), I can run the plan. I'm on the legacy free plan of Terraform cloud and tried posting the same question on their community site but have yet to get a response.

Background info:

Using Windows 10, I have upgraded Terraform via Chocolatey from version 1.6.2 to version 1.6.3. The folder structure or the settings in Terraform cloud for the project have not changed on my end. Terraform cloud is tracking the state of the workspace.

All terraform projects are giving the same error, since about mid-day last Friday the 17th. I have uninstalled Terrafrom via Chocolatey and restarted the computer. I then proceeded to install it again and it installed version 1.6.4. Error still occurs when I run ‘terraform plan’ on Terraforms' infrastructure. I tried contacting Terraform support but since I’m on the free plan, I only have community support.

Any suggestions? Thanks for your time in advance.

Update: If I pull the .tf files out of the subdirectory and put them in the root directory, everything works. But if I put them in a "infra" folder and change the working directory in TFC to either "/infra" or "infra" the error comes back. Seems like something between my computer and Terraform Cloud backend is causing this.

Folder Structure:

repo-root/
├─ infra/
│  ├─ .terraform/
│  │  ├─ providers/
│  │  ├─ environment
│  │  ├─ terraform.tfstate
│  ├─ locals.tf
│  ├─ main.tf
|  ├─ terraform.tf
│  ├─ variables.tf
├─ lambda/
│  ├─ helpers/
|  |  ├─ helper.js
│  ├─ index.mjs
│  ├─ package.json
│  ├─ package-lock.json
├─ .gitignore
├─ .terraformignore
├─ README.md

Solution

  • This was a bug that was fixed by the HashiCorp development team as of 2024-02-28. Had to delete the .terraform folder locally and then run terraform init.