> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/cost-estimation.md).

# Cost Estimation

Learn how to enable and use Infracost cost estimation for IaCM Terraform and OpenTofu plans.

Harness IaCM uses [Infracost](https://www.infracost.io/) to estimate the monthly cost change of each Terraform or OpenTofu plan. The estimate appears in approval steps and in the **Cost Change Estimation** tab, so you see the financial impact of a change before you apply it.

For the actual cost of resources a workspace already manages, and the savings recommendations for them, go to [Cost Management Agent integration](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/cloud-cost-management-integration.md).

***

## Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Confirm the following before you enable cost estimation:

* **Workspace configuration access:** You need **View** and **Edit** permissions for IaCM workspaces to enable cost estimation. Go to [Workspace RBAC](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/workspace-rbac.md) to configure permissions.
* **Terraform-based workspace:** Cost estimation works with Terraform and OpenTofu workspaces. Go to [Create a workspace](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/create-workspace.md) to set up a workspace.
* **Paid Infracost Cloud (optional):** Add an Infracost API key only if you subscribe to a paid Infracost Cloud plan and maintain custom pricing there. Go to [Infracost Cloud](https://www.infracost.io/) and [Infracost documentation](https://www.infracost.io/docs/) for account types and setup.

***

## How cost estimation works <a href="#how-cost-estimation-works" id="how-cost-estimation-works"></a>

Harness IaCM integrates with Infracost to estimate cloud infrastructure costs by analyzing Terraform plan output. When enabled, Harness automatically runs Infracost during every Terraform plan operation and calculates the estimated monthly cost difference based on current cloud provider pricing.

### Key characteristics <a href="#key-characteristics" id="key-characteristics"></a>

Cost estimation has the following key characteristics:

* **Approximations only:** Cost estimates may differ from actual costs based on your cloud provider agreement, usage patterns, and regional pricing variations.
* **Infrastructure focus:** Estimates cover infrastructure costs (compute, storage, networking) but not usage-based charges like data transfer or API calls.
* **Cloud provider support:** Works with AWS, Azure, and Google Cloud Platform.
* **Infracost Cloud API key (optional):** Harness integrates Infracost into IaCM, so estimates use public list prices from the open-source pricing data without an Infracost Cloud account. Set `INFRACOST_API_KEY` only if you have a **paid** Infracost Cloud plan **and** you define custom pricing in Infracost Cloud; otherwise, the key does not add value.

***

## Enable cost estimation <a href="#enable-cost-estimation" id="enable-cost-estimation"></a>

Cost estimation is controlled from the **Cloud Cost Integration** section of the workspace **Configuration** tab.

1. In your IaCM project, go to **Workspaces**.
2. Select the workspace you want to configure.
3. Go to the **Configuration** tab.
4. Under **Cloud Cost Integration**, toggle **Cloud Cost Estimation** on. Estimates appear in approval steps and the Cost Change Estimation tab.

<div data-with-frame="true"><figure><img src="https://3575326923-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffhx6XzjvtJmfv5gPWZ5m%2Fuploads%2Fgit-blob-56aca957a9b16d2e0d5e5eff6a232ab50ec88155%2Fcloud-cost-integration.png?alt=media" alt="Cloud Cost Integration section of the workspace Configuration tab with the cost estimation and Cloud Cost Management Integration toggles"><figcaption></figcaption></figure></div>

Settings apply immediately. Future pipeline executions reflect the updated configuration.

***

## Where to view cost data <a href="#where-to-view-cost-data" id="where-to-view-cost-data"></a>

### Approval steps <a href="#approval-steps" id="approval-steps"></a>

When your pipeline includes an approval step after a Terraform plan, the approval interface displays Infracost cost estimates alongside resource changes. This allows approvers to review the estimated financial impact before authorizing the apply operation.

<figure><img src="https://3575326923-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffhx6XzjvtJmfv5gPWZ5m%2Fuploads%2Fgit-blob-a13314403d4f7ed327d1a26e094d00013f9b1bdd%2Fcost2.png?alt=media" alt="Cost estimates in approval step"><figcaption><p>Click to view full size</p></figcaption></figure>

*Infracost cost estimates displayed in the approval step alongside resource changes*

The approval step shows the estimated monthly cost difference (increase or decrease) compared to the current infrastructure state.

### Cost Change Estimation tab <a href="#cost-change-estimation-tab" id="cost-change-estimation-tab"></a>

For a complete audit trail, Harness stores Infracost cost estimation data for every pipeline execution in the **Cost Change Estimation** tab. You can review historical cost estimates for past runs, compare cost impacts across different changes, and track infrastructure spending trends over time.

<figure><img src="https://3575326923-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffhx6XzjvtJmfv5gPWZ5m%2Fuploads%2Fgit-blob-343179bdfeb52ddd5379e4eb7cde178045a64bc3%2Fcost3.png?alt=media" alt="Cost Change Estimation tab"><figcaption><p>Click to view full size</p></figcaption></figure>

*Cost Change Estimation tab showing historical Infracost data for pipeline executions*

This tab is available in the pipeline execution details view and persists the cost data even after the pipeline completes.

***

## Configure Infracost Cloud (optional) <a href="#configure-infracost-cloud-optional" id="configure-infracost-cloud-optional"></a>

Harness integrates Infracost into IaCM. Cost estimation uses Infracost's open-source pricing database and public list prices by default, so you get estimates without signing up for Infracost Cloud.

Configure an Infracost Cloud API key **only** when you meet **both** of the following:

* You subscribe to a **paid** Infracost Cloud plan.
* You maintain **custom pricing** in Infracost Cloud (for example, enterprise discounts or negotiated rates), and you want those rules applied to estimates in IaCM.

If you do not need custom pricing or do not have a paid Infracost Cloud plan, skip this step. An API key does not change the default experience.

To connect a paid Infracost Cloud organization that uses custom pricing:

1. Use your paid Infracost Cloud account at [Infracost Cloud](https://www.infracost.io/).
2. Generate an API key from the Infracost dashboard. Go to [Infracost documentation](https://www.infracost.io/docs/) to follow the setup instructions.
3. In your workspace, go to the **Connectors and Variables** tab.
4. Under **Environment Variables**, select **+ Add Variable**, enter `INFRACOST_API_KEY` as the key, and your API key as the value.

With a valid key from a paid plan, Infracost can apply the custom pricing rules you configure in Infracost Cloud where supported.

***

## Limitations <a href="#limitations" id="limitations"></a>

Be aware of these limitations when using cost estimation:

* **Cloud provider support:** Cost estimation supports AWS, Azure, and Google Cloud Platform. Other cloud providers are not currently supported.
* **Resource coverage:** Not all Terraform resources have cost estimates. Infracost maintains pricing data for common infrastructure resources (compute instances, storage, databases, networking), but some specialized or newer resource types may show as "unsupported" or display $0 estimates.
* **Estimation accuracy:** Cost estimates are approximations based on standard pricing. Actual costs may vary due to enterprise agreements, reserved instances, committed use discounts, spot pricing, or usage-based charges that cannot be predicted from Terraform plans alone.
* **OpenTofu compatibility:** Cost estimation works with both Terraform and OpenTofu workspaces, but ensure you are using a recent version of Infracost that supports your OpenTofu version.
* **Performance impact:** Enabling cost estimation adds minimal overhead to Terraform plan operations. Most plans complete within seconds, but very large plans with thousands of resources may see a slight increase in execution time.

***

## Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

<details>

<summary>Cost estimates do not appear after enabling cost estimation</summary>

Verify that your pipeline includes a Terraform plan operation. Cost estimates only appear for plan operations, not for apply-only runs. Check the workspace Configuration tab to confirm cost estimation is toggled on.

</details>

<details>

<summary>Infracost API errors or authentication failures with Infracost Cloud</summary>

Verify the INFRACOST\_API\_KEY environment variable is correctly set in the workspace Connectors and Variables tab under Environment Variables. Test your API key by running \`infracost auth login\` locally. Ensure your Infracost Cloud account is active and the API key has not expired.

</details>

<details>

<summary>Cost estimate shows $0 or unavailable for specific resources</summary>

Some Terraform resources are not supported by Infracost's pricing database. Check the Infracost documentation for supported resources at <https://www.infracost.io/docs/supported\\_resources/>. If you need estimates that reflect negotiated rates, you need a paid Infracost Cloud plan with custom pricing and an API key configured as described under Configure Infracost Cloud (optional).

</details>

<details>

<summary>Cost estimate differs significantly from actual cloud bill</summary>

Cost estimates are based on standard cloud provider pricing and cannot account for enterprise agreements, reserved instances, spot pricing, or usage-based charges. Review your cloud provider's billing dashboard to understand the source of cost differences. Use cost estimates as directional guidance, not exact predictions.

</details>

***

## Next steps <a href="#next-steps" id="next-steps"></a>

Now that you understand how cost estimation works in IaCM, explore related workspace and governance topics:

* [Create a workspace](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/create-workspace.md): Learn how to create and configure workspaces.
* [Workspace RBAC](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/workspace-rbac.md): Control who can enable cost estimation and view cost estimates.
* [IaCM pipelines](https://developer.harness.io/infrastructure-as-code-management/platform/iacm-pipelines.md): Understand how cost estimates integrate with Terraform plan and approval steps.
* [Infracost documentation](https://www.infracost.io/docs/): Optional Infracost Cloud setup, API keys for paid plans, and supported resources.

{% @harness-feedback/feedback %}
