1. [Home](<https://delaparra-services.nl/>) 
1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) 
1. [state lock](<https://delaparra-services.nl/knowledge-hub/state-lock>)

  

Category: Terraform 

# state lock

  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    

## What is state lock?

 

state lock: A mutex that stops two people running apply at once and corrupting state. The S3 backend uses DynamoDB (or native locking) for this. A state lock stops two Terraform runs from changing the same state at the same time. When someone runs ` plan ` or ` apply `, Terraform takes the lock; anyone else has to wait until it is released.

 

Definition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)

 

## Frequently asked questions about state lock

  

### How is state lock used in practice?

 

Without locking, two simultaneous applies can both read the old state, make different changes and overwrite each other's records. The state then no longer matches reality, which is painful to repair.

    

### What should you keep in mind with state lock?

 

Most remote backends support locking; the S3 backend uses DynamoDB or, in newer versions, native S3 locking. If a run crashes and leaves the lock behind, ` terraform force-unlock ` with the lock ID releases it. Only do that when you are sure no other run is still active, because unlocking during a real apply is exactly what locking is meant to prevent.

    

### What does an example of state lock look like?

 

```
terraform force-unlock
```

 

## At a glance

   CategoryTerraform Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026

 

## More Terraform terms

 

- [remote backend](<https://delaparra-services.nl/knowledge-hub/remote-backend>) 
- [resource](<https://delaparra-services.nl/knowledge-hub/resource>) 
- [state file](<https://delaparra-services.nl/knowledge-hub/state-file>) 
- [state mv / rm](<https://delaparra-services.nl/knowledge-hub/state-mv-rm>) 
- [taint](<https://delaparra-services.nl/knowledge-hub/taint-terraform>) 
- [ternary](<https://delaparra-services.nl/knowledge-hub/ternary>)

 

[All terms starting with S](<https://delaparra-services.nl/knowledge-hub#letter-s>)

 

## Skills

 

- ### Terraform safe workflow

 

Use when running or changing Terraform (or OpenTofu) - init, fmt, validate, plan, apply, destroy, import, state mv/rm, refresh, workspaces, remote backends, state locking, drift, taint/-replace. Enforces a plan-review-apply workflow and protects state.

 [View skill](<https://delaparra-services.nl/skills/terraform-safe-workflow>) [Download zip](<https://delaparra-services.nl/skills/terraform-safe-workflow/download>) 
- ### Terraform Module Library

 

Build reusable Terraform modules for AWS, Azure, GCP, and OCI infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components.

 [View skill](<https://delaparra-services.nl/skills/terraform-module-library>) [Download zip](<https://delaparra-services.nl/skills/terraform-module-library/download>)

 [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/state-lock/skills.zip>)

 

## Manuals

 

- [Kubernetes and Terraform: do you need them?](<https://delaparra-services.nl/manuals/kubernetes-en-terraform-heb-je-het-nodig>)

 

## Related services

 

- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)

Perhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet.

 

## Need any help?

 

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.

  [Get in touch](<https://delaparra-services.nl/availability>)

[HTML version](https://delaparra-services.nl/knowledge-hub/state-lock)
