DEV Community

Cover image for Did you know? Terraform S3 State Locking — No DynamoDB Needed
Ahmed Belal
Ahmed Belal

Posted on

Did you know? Terraform S3 State Locking — No DynamoDB Needed

Since Terraform v1.10, you no longer need DynamoDB for state locking.
Terraform introduced S3 Native Locking, which lets you lock your state file directly inside your S3 bucket — no DynamoDB table required.

🧩 How it works

Add this line to your backend configuration:

use_lockfile = true

Enter fullscreen mode Exit fullscreen mode

Terraform will:
• Create a .tflock file in your S3 bucket
• Prevent concurrent writes to the same state
• Automatically handle lock cleanup after operations

✅ Introduced in v1.10
✅ Stabilized in v1.11
⚠️ HashiCorp plans to deprecate DynamoDB locking soon

🧠 Before enabling in production
• Enable Versioning and Encryption on your S3 bucket
• Ensure your IAM policy includes:
GetObject, PutObject, DeleteObject
• Always test first in a dev/test environment

“Less complexity, same safety.”

Reference: https://developer.hashicorp.com/terraform/language/backend/s3

Terraform #DevOps #AWS #InfrastructureAsCode #CloudEngineering #HashiCorp #ABCloudOps

Top comments (0)