github.com/hugorut/terraform@v1.1.3/website/docs/language/state/locking.mdx (about)

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