Drift Detection
Detect infrastructure drift and reconcile live cloud resources with your IaCM configuration.
Drift occurs when the actual resources in your cloud environment differ from those defined in your OpenTofu or Terraform state file. This usually happens when someone makes manual changes, for example, modifying a resource directly in the cloud console instead of updating it through code.
Harness IaCM helps detect and highlight these discrepancies, enabling you to quickly reconcile the real infrastructure with your configuration. This is typically done using a provisioning pipeline, which ensures that your Git-based configuration is the source of truth.
Detect drift
To detect drift, follow these steps:
Create a Pipeline with an Infrastructure as Code Management stage, as described in Provision workspace.
Choose a Workspace or set it as a runtime input.
Select Detect Drift when prompted to choose an operation.

To schedule drift detection regularly, define a cron trigger for the pipeline.
Review drift details
When drift is detected, the pipeline fails and highlights the affected resources. You can review drift details in your pipeline and workspace.
In the pipeline
Go to the Resources tab. The Drift Changes section outlines all resources where drift was detected. Click a resource to see which attributes have changed.

In the workspace
Drifted resources are also visible in the Workspace view. Under the Resources tab, look for resources marked as Drifted.

Click a resource to view its drifted attributes.

Detect drift using YAML
You can also run drift detection by configuring a plugin step in your pipeline YAML. This is useful when you are customizing pipeline execution outside the UI.
Detect drift during provisioning
Harness IaCM can also detect drift during provisioning. If a provisioning pipeline identifies drift, that information is displayed in the Approval step and the Resources tab.

Resolve drift
To promote best practices, always treat your IaC repository as the source of truth. If drift occurs, consider the following options:
Reconcile the infrastructure using a provision pipeline to bring resources back in sync.
Use plan-refresh-only to refresh the state without applying new configuration changes.
Manually import or delete the drifted resources depending on your intent.
Remediate with the agent from the workspace Insights tab. Go to the IaCM Remediation Agent to reconcile drift with a generated pull request.
Resolve drift using plan-refresh-only
This pipeline shows how to handle drift without applying pending changes:

Last updated
Was this helpful?