Two applies against one state file at the same time produce a state that describes neither result, and the backend lock is the only thing that prevents it.
terraform {
backend "s3" {
bucket = "tfstate-example"
key = "production/terraform.tfstate"
region = "eu-west-2"
dynamodb_table = "tfstate-locks" # ← the lock
encrypt = true
}
}
# Error acquiring the state lock
# ID: 7f2a...
# Who: ci@runner-04
# Created: 2021-06-14 09:41:02
The lock table is a separate resource that is easy to omit, and without it the backend works perfectly until two people apply at once. force-unlock exists for the case where a process died holding the lock and is the most dangerous command in the tool — using it while another apply is genuinely running is how the corrupted state happens. The error message names who holds it, which is usually enough to resolve it with a conversation instead.