Problem Statement
Why is state management critical in IaC tools like Terraform, and what problems can occur if it is mishandled?
Explanation
State management records the current infrastructure configuration so that IaC tools know what exists, what to create, and what to destroy. In Terraform, the state file tracks resource metadata and dependencies. If state is mishandled or corrupted, it can cause drift between actual and expected infrastructure, lead to accidental resource deletions, or break dependency chains. Secure and consistent management of state—such as using remote backends with locking—is essential for collaboration and reliability.
