In the question
Question: How does Terraform protect itself where concurrent operations are run against the same configuration?
correct option: Terraform will lock your state for all operations that could write state, if supported by your backend
My question: Terraform also locks the state even when we run plan not just applying(writing to the state)
Lab link: MCQ - Terraform State - KodeKloud
From the documentation
State locking happens automatically on all operations that could write stateā¦ if the backend supports it.
plan
does not ever change the state. It only compares the state with the resources deployed and reports any differences - thus is a read-only operation.
If the state in a remote backend is write locked by another terraform process (e.g. one that is applying), then plan
may have to wait till the lock is released to get a copy of the state.
I tried running plan and apply on same resource
apply
failed with Error: Error acquiring the state lock when plan
was running.