Terraform Locked The Networking Stack And Walked Away. Is Force-Unlock Safe??

Solvediacstateterraform4 replies · 330 views · started
Accepted solution by Cyrus — Before unlocking, make sure the holder is realy gone. The error shows Who, Operation and Created. Check that CI job and that colleagues…
  1. we run Terraform from two separate pipelines that share teh same Terraform Cloud state for teh networking stack :/ since this week, one of them rnadomly fails with:

    retrying usually works. is this just a race, and how do people normally avoid it??

    Our setup grew organically, and nobody planned for two pipelines touching the same state ;) Its annoying, but at least nothing broke yet. Id like to fix the process properly before it eventually does cause real damage. pls help 🙏

    1
  2. hmmmm quick q is there any chance a process is still running, a CI job still alive or someones laptop mid-apply? ?

    4 0 helpful
  3. ahh classic never Ctrl+C an apply twice, the first interrupt lets Terraform finish in-flight operations and release the lock; the second one kills it immediately and that's what leaves stale locks and half-written resources. worked for me anyway 🤷

    1 0 helpful
  4. Accepted solution

    Before unlocking, make sure the holder is realy gone. The error shows Who, Operation and Created. Check that CI job and that colleagues machine. If no process is running, its safe to run:

    terraform force-unlock <LOCK_ID>
    

    Force-unlock only removes teh lock entry, it does not change state contents.

    1 4 helpful

Reply to this topic

Sign in or create an account to reply.