Picture a small data team that discovers that its staging database had been running with a different instance size for weeks. Nobody remembered changing it. The code said one thing, the console said another, and the only reason anyone noticed was a billing line that looked odd. That small mystery is the everyday face of InfraOps, and the cure is a routine you can set up in an afternoon. The sequence below is the order in which I would assemble it.
Step 1: Decide what you are comparing
Drift only has meaning if there is a declared intention to drift away from. Before you automate anything, confirm that the resources you care about are described in code and that your tooling holds a record of them. The Ops Atlas calls these two items the code and the state, and it treats the live provider account as a third copy. Your routine compares the third against the first two. If a resource exists only in the console, this routine cannot see it, and later we will deal with that blind spot.
Step 2: Run a preview on a timer, not on a hunch
The simplest drift detector is a scheduled preview. With Terraform-style tooling you ask for a plan with the detailed exit code switched on. The command ends with exit code 0 when nothing differs, 1 when something broke, and 2 when changes are pending. Wire that exit code into a nightly job and you have a machine that taps your shoulder only when the copies disagree. A story helps here: that team had been running previews only when they wanted to deploy, so a quiet week hid three weeks of silent edits.
Step 3: Learn to read what a difference means
Not every difference is an intruder. Some tools compare only the properties you explicitly set, and others report cosmetic mismatches. The Atlas gives one concrete example from CloudFormation, where a value of 1024 megabytes and a value of 1 gigabyte can raise a false alarm, and it mentions that Bicep’s what-if feature can flag properties as deleted when they were not. Spend your first week tagging alerts as real, cosmetic or unclear. After a few cycles you will know which resources are noisy and can adjust your expectations rather than ignore the alert channel.
Step 4: Choose between accepting and correcting
When a preview shows drift you have two honest options. You can change the code so it matches the new reality, or you can apply the code and push reality back. A refresh-only plan is a third tool: it lets the state absorb what the provider shows without modifying any infrastructure, which is useful when the manual change was legitimate and you just need the record updated. Decide per case. A hot fix made during an outage often deserves to be written into code, while a casual tweak made out of curiosity deserves to be reverted.
Be careful with automatic correction. The Atlas warns that a blanket auto-revert is really an unreviewed apply pipeline holding strong credentials. Its suggestion is to allow it only for modules without durable data and only while no incident is open, and to use alert-and-assign with a 72-hour target everywhere else.
Step 5: Give every alert an owner and a clock
Alerts nobody owns turn into wallpaper. Route each drift notice to a named team and agree on how long it may stay open. Write down the age of each drift when you close it, because that age is the number that tells you whether the routine works. A week of alerts that all close within a day tells a very different story from a week where one stays open for a fortnight.
Step 6: Go looking for what the preview cannot see
The blind spot from Step 1 is the unmanaged resource. The Atlas notes that a clean plan proves nothing about objects the tooling never heard of. In a public drift tutorial it cites, a hand-made security group appeared only as an anonymous identifier in a diff. So once a month, list what exists in the account and compare the list with what the code claims. Anything extra is a candidate for import, adoption or deletion.
Step 7: Keep the story honest for the people who read it
Share a short weekly note with the team: how many previews ran, how many reported changes, how old the oldest open drift is. It will feel repetitive, which is good. Teams that write the note for a month tend to find that the same two or three modules generate most of the noise, and that is where a fix pays off.
If you enjoy the machine-learning side of operations, this thinking connects with how models are monitored in production. Our piece on how data-driven systems sharpen business decisions covers the downstream use of reliable signals, and the walkthrough on the way image classifiers interpret pictures shows why trustworthy inputs matter.
Where to read more
The full reasoning behind the three copies, the exit codes and the false-positive notes lives in this long Ops Atlas page on InfraOps. Read the drift section first, then return to your own account with a notebook.
Back to our imagined data team: after wiring a nightly job, the first run reported two differences. One was the mystery instance size, and it had been open for just over two weeks. They wrote the new size into code, set an owner for the next alert, and finally went back to sleep. A routine this small is not glamorous, but it is the part of InfraOps that gives you quiet nights.