Interview Prep/Terraform/State Internals

What is the structure of the state file and what are `serial` and `lineage`?

AdvancedConceptState Internals
Answer

It is JSON with version (format), terraform_version, serial (incremented on every write), lineage (a UUID fixed when state is created), outputs and resources. Backends reject writes whose serial is older than stored state, and refuse pushing state of another lineage, which prevents overwriting one stack's state with another's.

All Terraform questions Roadmap: Terraform in production

More on State Internals