Reference · Terraform

Remote State & Backends

State as a shared, locked, versioned artifact — the modern (2025+) S3 setup.

The canonical modern S3 backend block

terraform {
  backend "s3" {
    bucket       = "acme-terraform-state"
    key          = "prod/network/terraform.tfstate"   # ← your isolation strategy lives here
    region       = "us-east-1"
    encrypt      = true
    use_lockfile = true                              # S3-native locking (TF ≥1.10)
  }
}
Stale-tutorial alert: most older guides add a dynamodb_table for locking. That's the old way — Terraform 1.10 introduced S3-native locking via use_lockfile = true (S3 conditional writes create a .tflock object), and the DynamoDB arguments are deprecated since 1.11. New projects: lockfile only. Migrating: you can set both during transition, then drop DynamoDB.

Source: S3 backend reference

Why remote state at all

Backend facts that matter

Lock-related commands & flags

Command / flagUse when
-lock-timeout=5mInstead of failing instantly on a held lock, wait up to N for it to free (CI queues).
terraform force-unlock LOCK_IDA crashed run left a stale lock. Verify no run is actually active, then unlock with the ID from the error message.
-lock=falseAlmost never. Disables locking for one operation — a footgun kept for emergencies.

State bucket hardening checklist (AWS)

Source: AWS Prescriptive Guidance — backend best practices