Terraform interview question · Most asked

What is drift, and how do you detect and handle it?

Summary

Drift is a difference between the real infrastructure and what Terraform's configuration and state say, usually from manual console changes, other tools or scripts, or provider-side defaults changing. terraform plan (which refreshes state) shows it; scheduled plan runs in CI or HCP Terraform drift detection catch it continuously.

Longer Answer

When you find drift, decide whether the real-world change should be kept (update the configuration to match, possibly with ignore_changes for values another system owns) or reverted (apply the configuration). The real fix is process: restrict console write access in production, route changes through code review, and alert on drift. terraform plan -refresh-only updates state to match reality without changing infrastructure.

Key Points

  • Reality differs from config/state.
  • Detect with scheduled plans.
  • Adopt or revert, deliberately.
  • Prevent with access controls and process.

More most-asked Terraform questions

← All Terraform questions