HeadlinesBriefing favicon HeadlinesBriefing.com

Fixing Terraform State Locks in GitHub Actions

DEV Community •
×

A developer encountered the classic "state blob is already locked" error when running Terraform in GitHub Actions. The issue stemmed from an Azure Blob Storage lease that wasn't released after an interrupted pipeline job, preventing subsequent runs from acquiring the lock.

Diagnosis revealed the lock was storage-level, not local, confirmed by a persistent lock ID and the "Leased" status in Azure. The fix required manually breaking the lease in the Azure Portal, which immediately restored functionality and highlighted the critical role of backend state management in CI/CD.

To prevent recurrence, the author recommends using GitHub Actions concurrency groups, adding lock timeouts to Terraform commands, and using separate state files per environment. A structured workflow pattern combining these practices can avoid 99% of locking issues, ensuring reliable infrastructure automation.