ADR-0005: S3 native state locking, no DynamoDB#

  • Status: accepted
  • Date: 2026-07-30

Context#

Terraform's S3 backend historically required a DynamoDB table for state locking, because S3 had no conditional-write primitive. S3 gained conditional writes, and Terraform 1.10 added use_lockfile to the S3 backend, which implements locking with a .tflock object. DynamoDB-based locking is now deprecated and slated for removal.

Decision#

Use use_lockfile = true in the S3 backend. Create no DynamoDB table.

Alternatives considered#

DynamoDB table with dynamodb_table. The pattern every tutorial still teaches. Rejected because it is deprecated, requires a second service, needs its own IAM permissions in both CI roles, and costs ~$0.25/month for something the backend now does natively.

No locking at all. Defensible for a single-operator repository — but the CI apply job and a local apply could still collide, and a corrupted state file is the worst outcome available here. Locking is free now.

HCP Terraform for state. Free tier, nicer UX, built-in run history. Rejected because it adds a non-AWS dependency and an external service holding the state for infrastructure whose whole point is being self-contained and inspectable.

Consequences#

Positive: one less service, one less resource, one less set of IAM permissions, no monthly cost. Fewer moving parts in the bootstrap layer. Aligned with where the backend is going rather than where it has been.

Negative: requires Terraform 1.10+, which is not a constraint here. Locking semantics are newer and less battle-tested than DynamoDB's, though the underlying S3 conditional-write primitive is strongly consistent.

Neutral: a stale lock is cleared with terraform force-unlock exactly as before, or by deleting the .tflock object.

Interaction with the read-only plan role#

Native locking makes a nice property possible. Because tofu plan does not mutate state, CI runs it with -lock=false — so the plan role needs no S3 write permission at all, and carries an explicit Deny on state writes.

A pull request, including one from a fork, therefore cannot reach a credential capable of modifying state. That is a stronger guarantee than "the plan job probably will not write anything".

Revisit when#

Never, realistically. dynamodb_table will be removed from the backend and this becomes the only option.

Built 2026-11-25 from commit 33bfabf6a27d4baeecf228c31bd5d636a3965070. This page was generated from the same source that provisions the infrastructure it describes.