Skip to content
Latchkey

Pulumi "up" Shows an Unexpected Diff - Fix Drift in CI

Pulumi previewed changes you did not expect - a replace, an update, or a delete - because the real cloud state drifted, a provider upgrade changed how a resource is modeled, or an input is non-deterministic.

What this error means

pulumi preview in CI lists changes (often ~update or +-replace) for resources nobody edited. The same program against the same stack keeps showing the diff until the cause is reconciled, so the deploy is never a clean no-op.

pulumi output
Previewing update (prod):
    Type                 Name        Plan        Info
~   aws:s3:Bucket        assets      update      [diff: ~tags]
+-  aws:ec2:Instance     web         replace     [diff: ~userData]

Common causes

Real drift outside Pulumi

Someone changed the resource in the console or another tool. Pulumi compares desired state to actual and proposes reverting the out-of-band change.

Provider upgrade or non-deterministic input

A new provider version changes defaults or how a property is computed, or an input derived from a timestamp/random value differs each run, so Pulumi sees a change every time.

How to fix it

Refresh state, then read the precise diff

Reconcile Pulumi’s view with reality first, then inspect exactly which property changed with --diff.

Terminal
pulumi refresh --yes --stack org/proj/prod
pulumi preview --diff --stack org/proj/prod

Pin the provider and stabilize inputs

  1. Pin the provider version in the program so an upgrade does not silently reshape resources.
  2. Replace non-deterministic inputs (timestamps, random ids) with stable values or a RandomId resource Pulumi tracks.
  3. If the drift is intentional, apply once to absorb it, then keep changes flowing through Pulumi only.

How to prevent it

  • Run pulumi preview in PR checks so unexpected diffs surface before deploy.
  • Pin provider versions and bump them deliberately.
  • Make all infra changes through Pulumi, not the console, to avoid drift.

Frequently asked questions

What causes "unexpected preview diff"?
Someone changed the resource in the console or another tool. Pulumi compares desired state to actual and proposes reverting the out-of-band change.
How do I fix unexpected preview diff?
Reconcile Pulumi’s view with reality first, then inspect exactly which property changed with --diff.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card