The OpenAna Journal

Terraform drift from detection to a reviewed pull request

By OpenAna Engineering ·

An orange server block sits away from its matching position on an infrastructure blueprint

During a traffic spike, an on-call engineer raises a worker pool’s minimum size in the cloud console. The change buys capacity, but the repository still describes the old minimum. Days later, a Terraform plan proposes restoring the old setting. Before anyone applies it, the team needs to learn why the live setting changed and whether the service still relies on it.

Read the drift in context

Record the workspace, resource address, changed attribute and time of observation. Compare the live resource with the configuration and check the incident timeline or cloud audit event for an explanation. Give the service owner enough context to judge whether the difference is intentional, temporary or unexpected.

A refresh-only Terraform plan can show how state would change to reflect real infrastructure. Use a normal plan to see what Terraform proposes when it compares the configuration with the refreshed infrastructure view. Applying refresh-only can update state, while the configuration still requires its own review. HashiCorp Terraform plan reference

Pick the disposition before opening a change

Three common ways to resolve or track infrastructure drift
DecisionWhen it fitsReview artifact
Revert the live changeThe repository describes the agreed target and the service can safely return to it.Reviewed reconciliation plan, rollout timing and a rollback condition.
Codify the live changeThe service owner wants to keep the new setting.Configuration pull request with a plan showing the proposed impact in each affected environment.
Track a temporary exceptionThe service needs the new setting during a defined event or recovery window.Named owner, reason, expiry and follow-up to reconcile the difference.

Check the workspace before relying on the diff

Capture the identity and region associated with the workspace, the configuration commit and the time the plan ran. A plan can appear surprising simply because the engineer is looking at a different account, variable set or state backend from the one that owns the resource. Fix the inputs before asking a reviewer to interpret unexpected changes. If two tools legitimately manage the same resource, document the ownership boundary for the particular field and agree which system should reconcile it.

Follow the change from the plan to the service it affects. In the worker pool example, review both the capacity change and its impact on the shared database. A lower replica count may increase queue age, while the higher setting could exceed the connection budget under peak demand. This is why the service owner needs the incident context alongside the Terraform output. The infrastructure change is only one part of the decision.

Make the pull request useful to the reviewer

In the worker-pool example, the incident owner may decide to keep the higher minimum through a scheduled traffic event. If the team chooses to codify it, change the environment-specific input where possible. Editing a shared module default could also alter unrelated environments. Attach the plan for the intended workspace and flag any replacements, deletions or changes beyond the worker pool.

Define what to check after the rollout. For a worker pool, use backlog age, throughput and error rate over a comparable traffic window. Save the deployment reference and run a fresh plan to check for remaining differences. The person closing the change should be able to trace the original observation to the final state.

Leave a record for the next on-call engineer

Close the loop with the drift observation, the approved disposition, the applied revision and the post-change checks. If the console adjustment was a legitimate emergency action, add the corresponding reconciliation step to the runbook. A useful entry tells the responder when the exception expires and which workspace or service owner should review it. Track the age of open exceptions so temporary settings can be resolved before they become an undocumented part of the system.

Work through drift across two environments

Suppose staging and production use the same worker module, but only production needed emergency capacity. The on-call engineer changed the production minimum in the console. On the next plan, production shows a proposed change back to its old value. If the owner decides to keep the new minimum, add an explicit production input and rerun both plans. The production plan should reflect the chosen desired state. The staging plan should confirm that the shared module still behaves as expected there.

Next, check how ownership is split. The autoscaler may be responsible for current capacity, while Terraform owns the lower bound. Treat each attribute according to who is supposed to change it. Apply the same logic to cloud-generated fields and other external controllers. Record the intended boundary in the module or runbook so the next engineer can distinguish an expected adjustment from an unauthorized or unexplained configuration difference.

Where the plan shows a replacement or changes to a service outside the ticket, hold the review and trace the cause. Compare the plan input, workspace variables, provider and module versions, and resource address to the last successful apply. An unrelated module upgrade may be responsible. If the change can be isolated, send reviewers a smaller pull request and a fresh plan. This gives the owner a decision about the actual drift case without asking them to approve a second change by accident.

Use the same record at review and closure

  • Detection. Resource address, environment, observed value and intended value, with the timestamp and source.
  • Decision. Named owner, reason to keep or revert the change, and an expiry if it is temporary.
  • Delivery. Commit or pull request, plan for the intended workspace, and any dependency or policy checks.
  • Verification. Resulting live value, a fresh plan, and the service metrics relevant to the original incident.

A team reviewing repeated exceptions can look for their common cause. If operators keep raising the minimum before predictable traffic events, consider whether the capacity policy needs a scheduled override with a clear expiry. Keep that improvement on its own ticket so the emergency reconciliation can still be reviewed and closed independently.

Where OpenAna fits

OpenAna’s IaC Engine brings infrastructure generation, review and policy checks into the engineering workflow. In a pilot, give Ana one known drift case and ask it to prepare the change for your existing approval and delivery process. Evaluate whether the proposed pull request identifies the right resource, captures the reason for the change and gives the reviewer the plan they need.

For changes driven by spend, use the same review process with an added billing check. Cloud cost alerts and verified FinOps savings

Topics: Infrastructure as Code, Terraform, DevOps, Workflow guide

Related