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
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.
- Terraform >= 1.11.x
plancostprovider installed (or configured via development overrides)
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)
}Execute terraform plan. You will see the plancost_estimate resource being created (or updated) and a formatted cost breakdown in the outputs.
terraform planExample 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.
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
}
| 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) |
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
Explore our examples directory for complete use cases:
- Quickstart: Basic usage with Azure Public IP.
- Cost Guardrails: Enforce budget limits and cost increase policies.
- Tagging Policies: Validate required tags and allowed values.
- Usage Estimation: Improve accuracy with usage files (also see Inline Usage and Wildcards).
- CI/CD Integration: GitHub Actions workflow example.
- Pull Request Comments: Export estimates for PR comments.
- Policy as Code (OPA): Advanced policies using Rego.
- Cost Optimization: Get recommendations for cost savings.
- Simple Discounting: Apply negotiated discounts to estimates.
- Variables: Working with Terraform variables and
.tfvarsfiles.
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.
By submitting a Pull Request, you agree that your contributions are licensed under the Mozilla Public License 2.0.
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.
