Prompt
Why does my infrastructure drift keep coming back after apply?
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
Infrastructure drift usually “comes back” after apply because something else is changing the infrastructure again after Terraform reconciles it, or because Terraform’s desired state doesn’t fully match how the platform behaves.
Common causes:
-
Another controller is modifying resources
- Kubernetes operators, cloud autoscalers, policy engines, service meshes, or platform controllers may rewrite fields after
apply. - Example: an HPA changes replicas, ingress controller changes annotations, AWS adds default tags.
- Kubernetes operators, cloud autoscalers, policy engines, service meshes, or platform controllers may rewrite fields after
-
Manual changes outside IaC
- Someone edits resources in the console/CLI, and Terraform later fixes them, but the manual process repeats.
-
A CI/CD pipeline or GitOps tool is reapplying different config
- Argo CD, Flux, Helm, Ansible, or a second Terraform workspace can overwrite the same resource.
-
Computed/default fields are being treated as drift
- The provider/API may populate fields dynamically.
- These aren’t always real drift; they’re “normalization” differences like reordered lists, defaulted values, timestamps, or server-generated IDs.
-
Provider bugs or API quirks
- Some providers continually detect changes because the remote API returns values in a different format than Terraform expects.
-
Imprecise configuration
- If your code doesn’t declare all important fields, Terraform may converge on one run but the next refresh reveals platform-imposed changes.
-
Immutable or eventually consistent systems
- The resource may not be fully settled when Terraform checks it, so it appears drifted until the next reconciliation.
How to diagnose it:
- Check who/what last modified the resource in cloud audit logs.
- Run
terraform planimmediately afterapplyto see the exact field that changes. - Compare the provider’s read-after-write behavior with the API response.
- Look for controllers/operators managing the same resource.
- Inspect whether the “drift” is only in computed fields or order-only differences.
How to fix it:
- Make one system the single source of truth.
- Stop manual edits or have them feed back into code.
- Add
ignore_changesonly for fields intentionally managed elsewhere. - Tune your Terraform config to match the platform’s actual behavior.
- Upgrade the provider if it’s a known bug.
- Separate ownership: Terraform manages base infra, controllers manage runtime fields.
If you want, I can help you debug a specific drift example if you paste:
- the resource type,
- the
terraform plandiff, - and what platform/controller manages it.