Overview - Why state should not be edited manually
What is it?
In Terraform, the state file is a record of all the resources it manages. It keeps track of what exists in your cloud or infrastructure and their current settings. This file is critical because Terraform uses it to know what changes to make when you update your infrastructure. Editing this state file by hand means changing this record directly, outside of Terraform's control.
Why it matters
If you manually change the state file, Terraform can get confused about what resources exist or their settings. This confusion can cause Terraform to delete or recreate resources unexpectedly, leading to downtime or data loss. Without this rule, managing infrastructure would be risky and error-prone, making automation unreliable.
Where it fits
Before learning this, you should understand what Terraform state is and how Terraform manages infrastructure. After this, you can learn about best practices for state management, such as using remote state storage and state locking to avoid conflicts.