Skill 6.1.1

Local state storage

Key Concepts

The local backend writes terraform.tfstate in the root module directory and keeps the previous version in terraform.tfstate.backup. It is the default, so a configuration with no backend or cloud block uses it automatically. A backend "local" { path = "state/dev.tfstate" } block changes the file location. The local backend locks state with operating system file locks, which protects only against concurrent runs on the same machine.

Local state is fine for learning and personal experiments, but it does not suit teams: colleagues cannot see or lock it, it can contain secrets on a laptop disk, and it is lost if the directory is deleted. State files should never be committed to version control.