Exercise 2: DynamoDB's Specific Role, and What Breaks Without It — Possible Solution ==================================================================== DynamoDB's role in the S3+DynamoDB backend pattern is exclusively LOCKING -- it holds no copy of the state file's actual contents at all (that's entirely S3's job). Before any operation that would write to state, Terraform attempts a conditional write to a lock record in the DynamoDB table; that write only succeeds if no lock record currently exists. If it succeeds, Terraform proceeds with its operation, holding the "lock." If it fails (because a lock record is already present), Terraform blocks and reports the error shown in the chapter, rather than proceeding. Storing state remotely in S3, on its own, ALREADY solves the "no shared record" half of the local-state problem -- every teammate now reads and writes the exact same object instead of separate local files. But S3 alone provides no mechanism preventing two concurrent writes to that same object from racing each other -- S3 will simply accept whichever PUT request arrives, exactly the same "last write silently wins" failure mode from Exercise 1, just now happening to a shared remote object instead of a shared local file. Storing state remotely changes WHERE the race condition can happen, but does nothing by itself to prevent the race condition from happening at all. Without DynamoDB (or an equivalent locking mechanism), two team members' applies against the same S3-hosted state could still both read the same state, compute independent plans, and have one's write silently clobber the other's -- the exact scenario Exercise 1 described, still fully possible even with "shared remote state" if locking isn't also part of the setup. WHY THIS WORKS AS AN ANSWER ------------------------------ This correctly separates the two DIFFERENT problems remote state alone vs. locking alone each solve (shared record vs. safe concurrent writes), rather than treating "remote backend" as one single fix, and explains precisely why S3 by itself doesn't prevent the same race condition Exercise 1 described.