Interview Prep/Real-World Interview/Multi-env and multi-account

Someone changed a security group in prod through the console during an incident. How do you detect and handle this kind of drift?

IntermediateScenarioMulti-env and multi-account
Answer

Situation read → Manual changes during incidents are sometimes necessary. The problem is when they're forgotten, then overwritten by the next apply, or left as hidden config.

What I'd do →

  1. Detect: a scheduled terraform plan -detailed-exitcode in CI for each stack (exit code 2 means drift), posting to Slack.
terraform plan -detailed-exitcode -lock=false -out=drift.tfplan; echo "exit=$?"
  1. Real-time detection: EventBridge rule on console-originated CloudTrail write events in prod.
  2. Decide per drift: if the manual change was right, codify it in Terraform; if not, apply to revert.
  3. Process: incidents allow manual changes, but the postmortem includes "codify or revert" as a tracked action.

Why → Drift that's detected the same day is easy; drift found six months later during an apply causes outages.

Interview tip → Mention -detailed-exitcode; it's how you make drift detection scriptable.

All Real-World Interview questions Roadmap: Interview readiness

More on Multi-env and multi-account