MidIaC & Automation

Your team provisions infrastructure with code. Why does idempotency matter, and what breaks without it?

What they are really testing: Whether you understand the declarative model behind IaC (desired state vs imperative steps) or just see Terraform as a fancy way to run scripts. They want you to connect idempotency to drift, repeatability, and safe re-runs.

A real interview question

Your team provisions infrastructure with code. Why does idempotency matter, and what breaks without it?

What most people say

drag me

Idempotency means the script runs cleanly each time, so it is just good practice to make scripts re-runnable.

It restates the word without the model. It misses the desired-state vs imperative distinction, says nothing about drift detection or state tracking, and gives no concrete failure mode, so it reads as vocabulary, not experience.

The follow-ups they ask next

  • Someone edited a resource directly in the console. What happens on the next apply, and what should the team do?

    The plan shows drift and will revert the manual change to match code. The fix is process: console changes should be imported into state or made through code, and ideally direct write access is restricted so the pipeline is the only path.

  • Two engineers run apply at the same time. What goes wrong and how do you prevent it?

    Concurrent applies can corrupt shared state. Use a remote backend with state locking (e.g. a locked remote state) so the second apply waits, and run applies from CI rather than laptops.

What the interviewer is listening for

  • Frames IaC as desired-state reconciliation, not scripting
  • Connects idempotency to safe retries
  • Explains drift detection and code-as-source-of-truth
  • Knows the plan/diff and state mechanism behind it

What sinks the answer

  • Treats IaC as just running shell scripts
  • No mention of state or drift
  • Cannot give a concrete failure mode
  • Unaware of state locking for concurrent applies

If you genuinely do not know

Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.

Idempotency means [applying the same config twice gives the same state] because the tool [reconciles to a desired state]. It matters for [safe retries] and [drift detection so code stays the source of truth]. Without it you get [duplicate or half-applied resources]. Tools achieve it via [state tracking plus a plan/diff], which is why I [review the plan before apply].

Keep going with iac & automation

All 336 cloud engineer questions

Knowing the answer is not the same as recalling it under pressure

Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.

Start free