Interview Prep/Terraform/Lost, Corrupted and Drifted State

A nightly drift job reports drift in the morning that disappears by itself in the afternoon.

AdvancedTroubleshootingLost, Corrupted and Drifted State
Answer

Likely causes → Scheduled automation changes resources (instance scheduler stopping dev EC2 at night, scaling schedules, Lambda rotating something), or eventual consistency in APIs read during refresh.

Diagnose → Correlate drift timestamps with CloudTrail events and EventBridge schedules:

aws cloudtrail lookup-events --lookup-attributes AttributeKey=ResourceName,AttributeValue=i-0abc123 \
  --start-time 2026-11-08T00:00:00Z --max-results 20

Fix → ignore_changes on attributes owned by the automation, or move the drift job to a time when the environment is stable.

Prevent → Inventory every non-Terraform actor that writes to Terraform-managed resources and document ownership per attribute.

All Terraform questions Roadmap: Terraform in production

More on Lost, Corrupted and Drifted State