State is Terraform's record of which real resources correspond to which configuration addresses, plus cached attributes it uses to compute a plan. For a team it has to live in a remote backend with locking, such as S3 with native lockfile support or a managed backend, so two applies cannot run at once. Never commit it to git, since it holds secrets in plain text, and split it by blast radius rather than keeping one giant file.
Why interviewers ask this
State is where teams get hurt, so this question separates people who have run Terraform in production from people who have followed a tutorial. The interviewer wants to hear about locking, remote backends, secrets in state, and splitting state files. Follow ups usually go to recovery: what you do when state drifts, when someone deletes a resource by hand, or when an apply is interrupted halfway.
How to structure your answer
- Define state as the mapping between config and real resources.
- Explain why remote state plus locking is mandatory for a team.
- Cover secrets in state and access control on the backend.
- Describe how you split state and why blast radius drives it.
Example answer
State is the map between what I wrote in code and what actually exists in the provider, keyed by resource address, plus a cache of attributes so a plan does not have to read everything from scratch. On a team it goes in a remote backend with locking, so two people running apply at the same time cannot corrupt it. The thing that surprises people is that state contains resource attributes verbatim, so database passwords and generated keys sit in there in plain text; that means the bucket is encrypted, versioned, and locked down to the pipeline role, not readable by everyone. On layout, I split by blast radius and by change rate. Networking and accounts change rarely and get their own state, each service or environment gets its own, and they read from each other through data sources or published outputs rather than one root module holding everything. The practical reason is a five hundred resource state file makes every plan slow and every mistake enormous. For recovery I rely on bucket versioning plus state mv and import rather than editing the file by hand.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- What do you do if someone deletes a resource in the console?
- How would you refactor module structure without destroying resources?
- How do you recover from a state lock left behind by a crashed apply?
Related devops engineer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions