terraform icon indicating copy to clipboard operation
terraform copied to clipboard

State lock info / unlock for automation purpose

Open puzzloholic opened this issue 3 years ago • 1 comments

Current Terraform Version

Terraform v0.15.3
on linux_amd64

Use-cases

Sometimes state locking happens on a CI/CD pipeline when there is abrupt cancellation or unexpected command error because of networking issue (or someone still using terraform manually outside CI/CD) If this happens, the next run on the same pipeline will fail because the state is still locked. State unlock will have to be done manually. It would be great if there is a command to list locks on a certain state, or forcefully unlock all all available locks on a certain state without stating lock ID. All this to ensure that every run on the pipeline will have no state locked issue without automatic unlocking feature available.

Attempted Solutions

No solution available as there is no command to list locks available. Locks only visible when command plan or apply is executed and to unlock, a lock ID must be known.

Proposal

Maybe command like : terraform state lock list to list locks existing on a state, json output will be great for easy parsing. terraform state lock --unlock <lock-id> to unlock a certain lock. terraform state lock --unlock --all to force unlock all existing lock without stating lock ID

Or maybe implement a lock expiry time that can be configured globally or per state

References

  • #28194 state lock and unlock

puzzloholic avatar May 15 '21 04:05 puzzloholic

still on the roadmap ?

jtpham4 avatar Sep 20 '22 22:09 jtpham4

This is a needed feature

ldraney avatar Jan 28 '23 18:01 ldraney

I also want this feature added.

vadanx avatar May 10 '23 17:05 vadanx

this feature is required.

vijay-dcrust avatar Jul 05 '23 08:07 vijay-dcrust