Email copiado — support@tuurt.com
Cargando experiencia
devops · November 19, 2026 · 7 min

Shared remote state across teams in Terraform: why a single backend does not stop apply conflicts

Remote backends and locking keep the state file from corrupting, but they do not stop two teams from stepping on each other's changes. We look at why, and how splitting state by domain fixes it without slowing anyone down.

By Tuurt Team

Shared remote state across teams in Terraform: why a single backend does not stop apply conflicts

The same question comes up often: several teams work against the same infrastructure with Terraform, someone set up a remote backend on S3 with DynamoDB locking a while ago, and apply still produces surprises — changes nobody asked for, plans showing diffs on resources another team touched half an hour earlier, accidental rollbacks of configuration. The usual reaction is to assume the locking is broken. It almost never is. Terraform's locking does exactly what it promises; the problem is that it solves a different kind of concurrency than the one causing the conflicts.

Two concurrency problems that get confused with each other

The first is state file corruption: two Terraform processes writing to the same state file at the same time, which can leave it invalid or partially written. That is the problem remote locking solves.

terraform {
  backend "s3" {
    bucket         = "tuurt-terraform-state"
    key            = "infra/network/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "terraform-locks"
    encrypt        = true
  }
}

With this setup, when a team runs terraform apply, Terraform takes a lock on the DynamoDB table before writing, and any other apply or plan against the same state stays blocked until the first one finishes and releases the lock. That prevents corruption. It does not prevent the second problem, the one that actually hurts: two teams planning changes against the same set of resources without knowing about each other, so that one team's apply starts from a reality the other team's apply is about to change.

A Terraform plan is computed against the state as it exists at the moment terraform plan runs. If team A generates a plan at 10:00, reviews it, and only applies it at 10:40, while team B applied a change to the same module at 10:20, team A's plan is now describing a transition that no longer matches current reality. Locking does not catch this: the lock only exists during the apply execution itself, not during the gap between generating a plan and applying it. The typical outcome is that team A's apply silently reverts the change team B had just applied, because A's plan never saw it.

Why splitting by workspace is not enough

The instinctive answer is usually "let's use workspaces to separate the teams." Terraform workspaces were not built for that: they exist to multiply the same configuration across different environments — development, staging, production — reusing the same code with per-workspace variables. Two teams managing different infrastructure domains (networking, databases, applications) are not two environments of the same code; they are two different configurations that, if they share a workspace, also share a single state file and therefore the same locking bottleneck, even when the resources each one touches never overlap.

If the networking team needs to apply a routine change to a route table while the applications team is applying a change to an autoscaling group, both get serialized behind the same lock even though their changes have nothing to do with each other. That is not a corruption problem, it is a design problem: something that is really several independent domains of ownership got modeled as "one state."

Split state by domain, not by environment

The practice that actually fixes this is splitting state into multiple files, one per infrastructure domain or layer with a clear owner, instead of one monolithic state for the whole account. Networking in one state, databases in another, each service or group of services in its own.

# infra/network/main.tf -> its own state, platform team
# infra/database/main.tf -> its own state, data team
# infra/app-checkout/main.tf -> its own state, checkout team

When a module needs a value that lives in another domain's state — the ID of a VPC the networking team manages, for instance — it reads it with terraform_remote_state as a data source, never by copying the resource or duplicating its definition:

data "terraform_remote_state" "network" {
  backend = "s3"
  config = {
    bucket = "tuurt-terraform-state"
    key    = "infra/network/terraform.tfstate"
    region = "us-east-1"
  }
}

resource "aws_instance" "checkout_api" {
  subnet_id = data.terraform_remote_state.network.outputs.private_subnet_id
  # ...
}

With this split, the networking team and the checkout team no longer compete for the same lock: each one applies its own changes against its own state, and only blocks against another apply touching that exact same domain — the one case where blocking actually makes sense. The coupling between domains becomes explicit in the outputs each state exposes, instead of staying implicit in the fact that everyone shared the same file.

The cost this split does introduce

Splitting state is not free. It multiplies the number of backends to maintain, forces careful thinking about apply order when one domain depends on outputs from another that does not exist yet, and can create the opposite problem if taken too far: a state per individual resource makes plan slow because every apply has to read multiple external remote states, and figuring out which state has to apply first becomes a coordination problem of its own. The right split follows the team's real ownership boundaries — who can approve a change without asking another team for permission — not an arbitrary split by resource type.

What did not work the first time

On a project where two development teams shared the infrastructure of the same service, the initial design was one state per environment — one for staging, one for production — on the assumption that splitting by environment would already solve the concurrency problem. It worked fine as long as each environment had only one team touching it. The problem showed up once the second team started deploying its own component into that same production environment: every apply from one team blocked the other for minutes even when their changes were unrelated, and more than once an apply would finish waiting for the lock only to find that the plan it had prepared no longer matched reality, because the other team had applied something while it waited.

The fix was splitting the production state in two, following the real ownership boundary — team A's component in one state, team B's in another — and exposing as an output the small amount team A's component needed from team B's, read via terraform_remote_state. The lock wait times between those two teams disappeared, because they stopped sharing the resource that was causing the contention. The lesson was not that DynamoDB locking was misconfigured; it was that environment is the wrong axis to split state on when the real contention is between teams with different responsibilities inside the same environment.

What we check before signing off on a shared state design

Before approving a remote backend structure, we identify who can approve a change without depending on another team, and we use that ownership line — not the environment, not the resource type — to decide where one state ends and the next begins. We verify that dependencies between domains are explicit as outputs read via terraform_remote_state, never assumed as "that resource should already exist." And when the reported symptom is "locking isn't working," we check first whether the real problem is a plan that went stale relative to current state during the review window, before assuming the lock mechanism itself is broken.

terraform devops infrastructure aws
← Back to blog