Skip to content
ResOps

Configuration Drift: Changed, Missing and Unmanaged Resources

What configuration drift is, the three kinds to report separately, and why a refresh-only plan and a discovery inventory each answer a different part.

CloudEstate team · · 5 min read

Key takeaways

  • Drift has three kinds: changed (edited outside the pipeline), missing (deleted outside it) and unmanaged (never in any state file).
  • A refresh-only plan queries the provider per resource at the moment it runs, so it is authoritative for resources Terraform manages.
  • A discovery inventory is a snapshot, so it should answer only the question it alone can: which resources no state file claims.
  • Deriving missing resources from a stale inventory reports every freshly deployed resource as deleted.
  • A drift check that cannot plan a workspace should say it was skipped, not count it as clean.

Configuration drift is any difference between the infrastructure your code and state describe and the infrastructure actually running in the cloud account. It comes in three kinds: changed, missing and unmanaged. Detecting them correctly takes two sources of truth, a refresh-only plan for the resources Terraform manages and a discovery inventory for the ones it has never heard of, and most false drift reports come from asking the wrong source the wrong question.

What is configuration drift?

Infrastructure as code tools such as Terraform and OpenTofu keep a state: a record of the resources they manage and the attributes each had when last applied. Drift is what accumulates between that record and reality when changes happen somewhere else.

The usual causes are ordinary:

  • A security group rule is edited in the console during an incident and never written back to code.
  • A script or another tool modifies a resource the module also manages.
  • Someone deletes a resource by hand to "clean up".
  • Someone creates a resource by hand because it was faster than opening a pull request.

Drift matters for two reasons. The next apply will act on it, often by silently reverting an emergency fix. And anything changed outside the pipeline skipped the review, policy checks and approval that the pipeline exists to enforce.

What are the three kinds of drift?

KindWhat happenedWhat the next apply doesWhere the answer comes from
ChangedA managed resource was edited in the cloudReverts the editA refresh-only plan of the service that owns it
MissingA managed resource was deleted in the cloudRecreates itThe same refresh-only plan
UnmanagedA resource is running that no state file claimsNothing, because Terraform does not know it existsA discovery inventory, compared against every state

The consequences differ. Changed and missing drift will be acted on by the next apply whether you have looked at it or not. Unmanaged drift will never be touched by an apply, which is its own problem: it has no owner and no review.

Why is a refresh-only plan authoritative for managed resources?

A refresh-only plan asks the provider for the current attributes of every resource in the state, at the moment it runs, and reports how they differ from what the state recorded.

terraform plan -refresh-only

# OpenTofu
tofu plan -refresh-only

Three properties make it the right source for changed and missing resources:

  1. It is current. The answer is as fresh as the API call that produced it.
  2. It is per resource. Each managed resource is looked up by its own identifier, so there is no matching step to get wrong.
  3. It proposes no infrastructure changes. A refresh-only plan only describes how the state would be updated to match reality, which makes it suitable to run against production.

Its limit is equally clear: it can only ask about resources in the state, so it cannot notice a database created by hand last month.

Why use the inventory only for unmanaged resources?

A discovery inventory is the result of scanning a cloud account and recording everything found, managed or not. It is the only source that knows about resources outside every state file, so it is the only way to find unmanaged drift: take everything in the inventory, subtract everything claimed by any state, and what remains is unmanaged.

But an inventory is a snapshot from whenever discovery last ran. For any question a refresh-only plan can answer, the plan's answer is fresher and more exact. The rule that follows is simple: use each source only for what it alone knows.

Why is deriving "missing" from a stale inventory wrong?

It is tempting to compute everything from one comparison: resources in the state but not in the inventory are missing, and resources in the inventory but not in the state are unmanaged. The second half is sound. The first half is not.

Suppose discovery scanned the account at 09:00. At 14:00 a pipeline deploys a new queue and two instances. A drift check at 15:00 that compares state against the 09:00 inventory finds three resources in the state that the inventory has never seen, and reports all three as deleted. Nothing was deleted. The inventory is simply older than the deploy.

That failure is not an edge case. It fires on every freshly deployed resource until the next scan, which means the busiest services produce the most false alarms. The opposite error happens too: a resource deleted after the last scan is still in the inventory, so the comparison calls it healthy.

A refresh-only plan gets both cases right because it does not rely on a snapshot.

What should you do about each kind?

  • Changed. Decide whether the manual edit was correct. If it was, put it in the code so the next apply keeps it. If it was not, apply to revert it.
  • Missing. Find out why it was deleted before anything recreates it. Then either remove it from the code or let the apply bring it back.
  • Unmanaged. Import it into code so it has an owner and passes through review, or delete it if nobody claims it. Unmanaged resources that cost money are also a FinOps question, covered in recoverable waste vs unowned spend.

How CloudEstate handles this

The Configuration Drift page in the ResOps app runs terraform plan -refresh-only for each deployed service to find changed and missing resources, and compares the discovery inventory against every state to find unmanaged ones. It does not derive missing resources from the inventory.

A drift check writes nothing to the cloud account. Services whose workspace cannot be planned are listed as skipped, with the reason, instead of being counted as clean. The check also corrects the inventory's own unmanaged flag: discovery marks everything it finds as unmanaged, because at scan time it cannot know which state files exist, and the drift check reconciles that against the states.

Two related behaviors keep the unmanaged list trustworthy. A scan forgets resources it no longer finds, scoped to the regions and resource types it actually covered, so deleted resources do not linger as phantom findings. And discovery can write Terraform for what it finds, with a matching state file or an import script, which is the route from unmanaged to managed. Drift is one of the after-deploy questions described in what an internal developer platform is.

Frequently asked questions

It is the gap between what Terraform's state records and what exists in the cloud account. It appears when a resource is edited or deleted outside Terraform, or when resources are created that no state file tracks.

A refresh-only plan reads the current state of each managed resource from the provider and reports the differences. It never proposes changes to infrastructure, and a plan on its own writes nothing.

Terraform cannot report them, because it only knows about resources in its state. You need an independent scan of the account, compared against the resources claimed by every state file you have.

The report is probably comparing state against an inventory that was scanned before the resources were created. An inventory is a snapshot, so anything deployed since the last scan is absent from it.

  • configuration drift
  • terraform
  • infrastructure as code

Keep reading

FinOps

AWS Cost Optimization Tools vs Services: What Each One Fixes

14 min read
SecOps

SOC 2 Evidence From AWS Configuration: What It Can Prove

5 min read
SecOps

Policy Waivers: Exceptions With a Reason, Scope and Expiry

5 min read

Start with one scan

See your own account, not a demo of someone else’s.

Connect a cloud credential with read permissions and run one scan. The inventory, the diagram, the findings and the cost figures are all filled from it.

Read-only to start · no agent to install