Prerequisites:
- TFC/TFE workspace
- Configuration on local machine with remote backend or cloud integration initialized
- Configuration directory contains a non-empty
terraform.tfstate
file - Using Terraform v1.1.6 or earlier
Problem:
Running
terraform plan
or terraform apply
with Terraform v1.1.6 or earlier results in an error because the terraform.tfstate
file is uploaded along with the configuration, causing a conflict with the workspace's backend.Terraform v0.14.8 Initializing plugins and modules... Initializing the backend... Error: Error locking destination state: Error acquiring the state lock: resource not found Terraform acquires a state lock to protect the state from being written by multiple users at the same time. Please resolve the issue above and try again. For most commands, you can disable locking with the "-lock=false" flag, but this is not recommended. Operation failed: failed running terraform init (exit 1)
Solutions:
- Terraform v1.1.7 and later ignore the
terraform.tfstate
file when performing remote operations from a local machine. Upgrade to v1.1.7 or later. - Delete the local
terraform.tfstate
file that is causing the conflict.