Menu

Two Terraform root modules, one S3 key: state locking and backend collisions
📰

Two Terraform root modules, one S3 key: state locking and backend collisions

DEV Community: terraform·TANK JAY·3 days ago
#mEhD3N8Z
#devtoterraform#devto#dev#backend#terraform
Long article (407 words) — no AI summary yet.
Reading 0:00
15s threshold

Copy a Terraform root module to start a new one, trim the backend block, and forget to change key . A made-up but very typical example:

# app/backend.tf, copied from network/backend.tf backend "s3" { bucket = "acme-tf-state" key = "terraform.tfstate" # same key as network/ region = "eu-west-1" }

Enter fullscreen mode

Exit fullscreen mode

Both modules now write s3://acme-tf-state/terraform.tfstate . The next apply in one replaces the other's state, and the next plan in the other proposes to recreate everything it manages. Terraform never complains: it is a valid configuration.

What the docs actually say

S3 state locking is opt-in . use_lockfile defaults to false .

Terraform introduced use_lockfile as experimental in 1.10, made it generally available in 1.11, and deprecated dynamodb_table , which "will be removed in a future minor version".…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.