Configure Terraform S3 backend with native state locking (use_lockfile) without DynamoDB

domain: developer.hashicorp.com/terraform/language/backend/s3 · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Upgrade Terraform to 1.11 or later where native S3 state locking (`use_lockfile`) is generally available; in 1.10 it was experimental.
  2. In the S3 backend configuration block set `use_lockfile = true`; remove or stop adding the `dynamodb_table` argument (it is deprecated in 1.11 and will be removed in a future version).
  3. Ensure the S3 bucket has versioning enabled; Terraform uses S3 conditional writes (`If-None-Match`) to create a `.tflock` file alongside the state file, requiring S3 object conditional write support (available on standard S3 buckets).
  4. The lock file is named `<state-key>.tflock`; ensure the IAM policy for Terraform's identity includes `s3:PutObject`, `s3:GetObject`, and `s3:DeleteObject` on both `*.tfstate` and `*.tflock` object paths.
  5. Test locking by running two simultaneous `terraform plan` operations against the same state; the second should fail with a lock error until the first completes.
  6. For teams migrating from DynamoDB locking, remove the DynamoDB table reference from the backend config and the DynamoDB IAM permissions after verifying native locking works correctly.

Known gotchas

Related routes

Use OpenTofu native state encryption to encrypt Terraform-compatible state at rest with a passphrase-derived key before storing in an S3-compatible backend
opentofu.org · 5 steps · unrated
Use Terraform remote state with locking safely in a team
terraform · 4 steps · unrated
Use OpenTofu's native state encryption feature to encrypt Terraform state at rest with a passphrase-derived key before storing it in an S3 backend
OpenTofu · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans