Terraform Provider: plancost

January 22, 2026 · View on GitHub

License: MPL 2.0

The plancost provider allows you to estimate, track, and optimize cloud costs directly within your Terraform workflow. By integrating cost estimation as a native Terraform resource, you get cost visibility, policy enforcement, and security without leaving your infrastructure code.

Website: https://plancost.io

plancost demo

Overview

Unlike CLI wrappers, plancost works as a genuine Terraform Provider. This means cost data is stored in your state file, accessible to other resources, and verifiable by standard policy tools.

Prerequisites

  • Terraform >= 1.11.x
  • plancost provider installed (or configured via development overrides)

Quick Start

1. Setup

Install the plancost provider by adding it to your Terraform configuration.

terraform {
  required_providers {
    plancost = {
      source = "plancost/plancost"
    }
  }
}

resource "plancost_estimate" "this" {
  working_directory = abspath(path.module)
}

2. Run Terraform Plan

Execute terraform plan. You will see the plancost_estimate resource being created (or updated) and a formatted cost breakdown in the outputs.

terraform plan

Example Output:

Terraform will perform the following actions:

  # azurerm_public_ip.test will be created
  + resource "azurerm_public_ip" "test" {
      ...
    }

  # plancost_estimate.this will be created
  + resource "plancost_estimate" "this" {
      + monthly_cost = 3.65
      + resources    = {
          + "azurerm_public_ip.test" = {
              + cost_components = {
                  + "IP address (static, regional)" = {
                      + monthly_cost     = 3.65
                      + monthly_quantity = "730"
                      + unit             = "hours"
                    }
                }
              + sub_resources   = {}
            }
        }
      + view = <<-EOT
        Project: main
        
         Name                                                         Monthly Qty  Unit    Monthly Cost
        
         azurerm_public_ip.test
         └─ IP address (static, regional)                             730          hours   \$3.65
        
         OVERALL TOTAL                                                                     \$3.65
    EOT
    }

Plan: 3 to add, 0 to change, 0 to destroy.

3. Track Cost Changes

When you modify your infrastructure (e.g., changing a SKU), terraform plan will show the cost difference in the plancost_estimate resource and the output.

Example: Changing Public IP SKU from Standard to Basic

  # plancost_estimate.this will be updated in-place
  ~ resource "plancost_estimate" "this" {
      ~ monthly_cost = 3.65 -> 2.63
      ~ view = <<-EOT
        Project: main
        
         Name                                                         Monthly Qty  Unit    Monthly Cost
        
         azurerm_public_ip.test
      -  └─ IP address (static, regional)                             730          hours   \$3.65
      +  └─ IP address (static, regional)                             730          hours   \$2.63
        
      -  OVERALL TOTAL                                                                     \$3.65
      +  OVERALL TOTAL                                                                     \$2.63
    EOT
  }

Why plancost?

FeatureOthersplancost
SetupBinary Install + Auth + CI ScriptingCopy-paste 6 lines of HCL. No Sign-up.
WorkflowSeparate CLI commandNative terraform plan integration
Diff ViewMulti-step process / External DashboardInline in terraform plan output
Cost GuardrailsExternal Policies (OPA/Sentinel)Defined in HCL (Native Resource)
Tagging PoliciesExternal DashboardsDefined in HCL (Native Resource)
Platform SupportCustom hooks for Atlantis/TFCWorks out-of-the-box everywhere
Policy EnginesRequires custom input parsingNative HCL Resource
CI/CDRequires CLI InstallationZero-Install (Standard terraform init)
StateLocked in SaaS DashboardStored in terraform.tfstate
PrivacySends Configs, Names & Paths to SaaSAnonymous (SKU/Region only)

Supported Providers

Currently, plancost focuses on Microsoft Azure, providing deep coverage for the top 100+ most common resources (matching and exceeding other tools).

For a complete list of supported resources and their pricing status, see the Supported Resources guide.

  • Azure: ✅ Full Support (500+ resources)
  • AWS: 🚧 Planned
  • GCP: 🚧 Planned

Examples

Explore our examples directory for complete use cases:

Credits

This project uses source code from Infracost. We would like to thank the Infracost team for their amazing work in the cloud cost estimation space.

Contributing

By submitting a Pull Request, you agree that your contributions are licensed under the Mozilla Public License 2.0.

License

This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).

See the LICENSE file for specific terms and conditions.


This project also includes code from Infracost, which is licensed under the Apache License 2.0. See LICENSE_INFRACOST and NOTICE for details.