Skip to content

plancost/terraform-provider-plancost

Terraform Provider: plancost

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?

Feature Others plancost
Setup Binary Install + Auth + CI Scripting Copy-paste 6 lines of HCL. No Sign-up.
Workflow Separate CLI command Native terraform plan integration
Diff View Multi-step process / External Dashboard Inline in terraform plan output
Cost Guardrails External Policies (OPA/Sentinel) Defined in HCL (Native Resource)
Tagging Policies External Dashboards Defined in HCL (Native Resource)
Platform Support Custom hooks for Atlantis/TFC Works out-of-the-box everywhere
Policy Engines Requires custom input parsing Native HCL Resource
CI/CD Requires CLI Installation Zero-Install (Standard terraform init)
State Locked in SaaS Dashboard Stored in terraform.tfstate
Privacy Sends Configs, Names & Paths to SaaS Anonymous (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.

About

A Terraform Provider for cloud cost estimation with extensive Azure support. See the price tag of your infrastructure changes before you deploy.

Topics

Resources

License

MPL-2.0, Apache-2.0 licenses found

Licenses found

MPL-2.0
LICENSE
Apache-2.0
LICENSE_INFRACOST

Code of conduct

Stars

Watchers

Forks

Contributors

Languages