For the complete documentation index, see llms.txt. This page is also available as Markdown.

IaCM Remediation Agent

Use the IaCM Remediation Agent to generate pull requests that propose fixes for drift insights and CCM cost optimization recommendations.

This feature is in Beta and requires enablement. View all early access features.

Harness IaCM lets you act on workspace insights directly from the Insights tab. The Remediation Agent handles two types of insight: drift and cost optimization recommendations. For drift, it analyzes the gap between your OpenTofu or Terraform configuration and the actual cloud state, then generates a pull request with the configuration changes needed to close that gap. For cost recommendations sourced from Cloud Cost Management, it generates a pull request with the configuration changes needed to implement the recommendation. For example, rightsizing a cloud instance or shutting down an idle resource.

The agent does not change your infrastructure directly. It generates a pull request so you can review the proposed changes before merging. You merge the pull request and then provision the workspace to apply the change. This keeps your Git repository the source of truth and gives you a full review gate before any infrastructure changes take effect.


How remediation works

Remediation runs on the project's default remediation pipeline. You configure this pipeline once for the project in the IaCM Defaults, and it then applies to every workspace in the project. Harness does not remediate insights automatically; you start each remediation from the Insights tab. The flow is the same whether you are acting on a drift insight or a cost recommendation:

  1. Harness IaCM surfaces an insight on the workspace Insights tab: either a drift detection or a CCM cost recommendation.

  2. You click Apply with agent on the insight.

  3. Harness opens the Run Pipeline panel. Confirm the workspace and click Run Pipeline.

  4. The remediation pipeline runs a single Remediation Agent step.

  5. The agent generates a pull request with the proposed IaC changes for the affected resource.

  6. The insight moves from Open to Applied. Applied means the pull request has been generated. Your infrastructure has not changed yet.

  7. You review and merge the pull request, then provision the workspace to apply the change to your infrastructure.


Before you begin

Before you launch remediation, confirm the following are in place:

  • A workspace with an open insight: Insights appear on the Insights tab. Drift insights require drift detection to be configured. Cost optimization insights require Cloud Cost Management Integration to be enabled on the workspace. Go to Drift detection to configure drift detection, and go to Cost estimation to enable Cloud Cost Management Integration.

  • A default remediation pipeline: Configure the remediation pipeline for the project in the IaCM Defaults. Go to Default pipelines to review how defaults are configured.

  • Permission to run the pipeline and merge the pull request: Execute permission on the remediation pipeline and write access to the connected repository. Go to Workspace RBAC to review IaCM permissions.


Remediate an insight

Once an insight appears on the Insights tab, you remediate it in a few steps.

  1. Navigate to your workspace and select the Insights tab.

  2. Locate the open insight you want to remediate, then click Apply with agent.

    Apply with agent button on a drifted resource
  3. In the Run Pipeline panel, confirm the workspace, then click Run Pipeline.

    Run Pipeline panel for the remediation agent
  4. When the pipeline completes, the insight moves to Applied and the execution output shows a link to the pull request. Open the pull request link.

  5. Review the proposed changes in your repository, then merge the pull request and provision the workspace to apply the change to your infrastructure.

The Applied view shows the date and user who triggered the run, the estimated monthly savings (for cost recommendations), a SUCCESS or FAILED status, and links to the execution details and the pull request.

If the pipeline fails, the Applied view shows Pipeline failed. Try to apply again. Click Apply with agent again to re-run the remediation pipeline for that resource.


Cloud Cost Management recommendations

When Cloud Cost Management is connected to a workspace, the Insights tab also surfaces cost optimization recommendations sourced from Harness CCM, for example rightsizing an oversized EC2 instance or shutting down an idle Azure VM. The Apply with agent flow for cost recommendations is identical to the drift flow: clicking the button runs the project's default remediation pipeline, which generates a pull request with the recommended configuration change.

CCM cost recommendations are supported for AWS and Azure resources. GCP recommendations are not supported at this time. Go to Workspace Insights for the full list of supported resource types and recommendation actions.

To connect Cloud Cost Management to a workspace, go to Cost estimation and enable the Cloud Cost Management Integration toggle in the workspace configuration.


Troubleshoot remediation

If remediation does not behave as expected, the following cases cover the most common causes.

The Apply with agent button is missing from an insight in Harness IaCM

The IaCM Remediation Agent is a beta feature that requires enablement. Contact Harness Support to request access, and confirm a default remediation pipeline is configured for the project in the IaCM Defaults.

The IaCM remediation pipeline finished but no pull request was created

Open the Remediation Agent step logs in the execution output. If the agent found no changes to recommend for the affected resource, it does not generate a pull request.

The IaCM remediation pull request contains more changes than expected

When Cloud Cost Management is connected to the workspace, the agent can include both drift fixes and CCM cost recommendations for the same resource in a single pull request. Review the diff before merging. If you want the pull request to cover drift only, disable the Cloud Cost Management Integration in the workspace Configuration tab.


Next steps

With remediation configured, you can act on insights as soon as they surface.

  • Go to Insights to review the insights you can remediate and the supported CCM recommendation types.

  • Go to Drift detection to understand how Harness IaCM detects drift.

  • Go to Default pipelines to configure the remediation pipeline for your project.

  • Go to Cost estimation to connect Cloud Cost Management to your workspace.

Last updated

Was this helpful?