github.com/pdecat/terraform@v0.11.9-beta1/website/docs/state/locking.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "State: Locking"
     4  sidebar_current: "docs-state-locking"
     5  description: |-
     6    Terraform stores state which caches the known state of the world the last time Terraform ran.
     7  ---
     8  
     9  # State Locking
    10  
    11  If supported by your [backend](/docs/backends), Terraform will lock your
    12  state for all operations that could write state. This prevents
    13  others from acquiring the lock and potentially corrupting your state.
    14  
    15  State locking happens automatically on all operations that could write
    16  state. You won't see any message that it is happening. If state locking fails,
    17  Terraform will not continue. You can disable state locking for most commands
    18  with the `-lock` flag but it is not recommended.
    19  
    20  If acquiring the lock is taking longer than expected, Terraform will output
    21  a status message. If Terraform doesn't output a message, state locking is
    22  still occurring if your backend supports it.
    23  
    24  Not all [backends](/docs/backends) support locking. Please view the list
    25  of [backend types](/docs/backends/types) for details on whether a backend
    26  supports locking or not.
    27  
    28  ## Force Unlock
    29  
    30  Terraform has a [force-unlock command](/docs/commands/force-unlock.html)
    31  to manually unlock the state if unlocking failed.
    32  
    33  **Be very careful with this command.** If you unlock the state when someone
    34  else is holding the lock it could cause multiple writers. Force unlock should
    35  only be used to unlock your own lock in the situation where automatic
    36  unlocking failed.
    37  
    38  To protect you, the `force-unlock` command requires a unique lock ID. Terraform
    39  will output this lock ID if unlocking fails. This lock ID acts as a
    40  [nonce](https://en.wikipedia.org/wiki/Cryptographic_nonce), ensuring
    41  that locks and unlocks target the correct lock.