CodexBloom - Programming Q&A Platform

OCI Resource Manager: implementing Terraform State Locking in Multiple Workspaces

👀 Views: 99 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-13
oci terraform resource-manager hcl

I'm experiencing issues with Terraform state locking when using OCI Resource Manager with multiple workspaces. My setup involves separate workspaces for different environments like dev, staging, and production. Every time I try to apply changes in one workspace, I get the following behavior: ``` behavior: behavior acquiring state lock: ConditionalCheckFailedException: The conditional request failed ``` I have verified that I'm not trying to access multiple workspaces simultaneously, and I'm using Terraform 1.3.0. My backend configuration in the `main.tf` file looks like this: ```hcl terraform { backend "oci" { compartment_id = "<compartment_id>" resource_id = "<resource_id>" workspace = "dev" } } ``` I've tried using the `terraform force-unlock` command to manually release the lock, but I still face issues when switching to other workspaces. I also checked the OCI console to ensure that there are no locks present for the respective resources. Furthermore, I ensured that the IAM policies allow the necessary permissions for both the Resource Manager and the Object Storage backend. Any insights on why I'm running into this locking scenario? Are there specific configurations or best practices to follow when using multiple workspaces in OCI Resource Manager? This is hindering my workflow significantly, and I would appreciate any advice on resolving this question.