Interview Prep/Terraform/Import Refactoring Drift and Lifecycle

Someone opened port 22 on a security group in the console. Terraform wants to remove it. What's your process?

IntermediateScenarioImport Refactoring Drift and Lifecycle
Answer

Situation read → Revert or codify? Find out why it happened first.

What I'd do →

  1. Ask who changed it and why; check CloudTrail (AuthorizeSecurityGroupIngress).
  2. If it was an unauthorised or temporary change, run terraform apply to revert.
  3. If it's a legitimate need, add it to code through a PR, then apply.

Why → Terraform's job is to enforce the desired state, but humans decide what that state should be.

Interview tip → Mention follow-up: restrict console write access so drift becomes rare.

All Terraform questions Roadmap: Terraform in production

More on Import Refactoring Drift and Lifecycle