Infracost — Cloud Cost Estimates for Infrastructure as Code
See cloud cost breakdowns before you deploy. Infracost integrates with Terraform and CI/CD to show how every change impacts your bill.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install 49638173-3974-11f1-9bc6-00163e2b0d79 --target codex先 dry-run,确认写入项后再运行此命令。
What it is
Infracost is a CLI tool that generates cloud cost estimates from Terraform plans. Before deploying any infrastructure change, you can see exactly how it affects your monthly bill. It supports AWS, Azure, and Google Cloud with pricing data for hundreds of resource types. Infracost integrates with CI/CD pipelines to post cost diffs as pull request comments.
Infracost targets DevOps engineers and platform teams who want cost visibility as part of the infrastructure review process, not as an after-the-fact surprise on the cloud bill.
How it saves time or tokens
Cloud cost surprises typically surface weeks after deployment on the monthly invoice. Infracost shifts cost awareness to the planning stage. A developer proposing a change from t3.medium to r5.2xlarge sees the cost impact immediately in the PR comment. This prevents expensive mistakes and enables cost-informed architecture decisions without waiting for the finance team to flag anomalies.
How to use
- Install and authenticate:
brew install infracost
infracost auth login
- Generate a cost breakdown:
cd my-terraform-project
infracost breakdown --path .
- Compare costs between changes:
infracost diff --path . --compare-to infracost-base.json
Example
Infracost output for a Terraform plan:
Project: my-terraform-project
Name Monthly Qty Unit Monthly Cost
aws_instance.web
Instance usage (Linux/UNIX, on-demand, t3.medium) 730 hours $30.37
root_block_device - Storage (gp3) 20 GB $1.60
aws_rds_instance.db
Instance usage (on-demand, db.r5.large) 730 hours $175.20
Storage (gp2) 100 GB $11.50
OVERALL TOTAL $218.67
Related on TokRepo
- AI Tools for DevOps — infrastructure and cloud management tools
- AI Tools for Monitoring — cost monitoring and observability
Common pitfalls
- Infracost estimates are based on list pricing and usage assumptions; actual costs may differ due to reserved instances, savings plans, or usage-based resources
- Some resource types (Lambda invocations, S3 requests) require usage estimates in an Infracost usage file; without them, these costs show as $0
- Free-tier resources still appear with their standard pricing; Infracost does not account for AWS Free Tier eligibility
常见问题
Infracost supports AWS, Azure, and Google Cloud with pricing data for hundreds of resource types. Coverage is most comprehensive for AWS, with Azure and GCP having slightly fewer supported resources.
Infracost maintains a cloud pricing database updated regularly from official cloud provider pricing APIs. The CLI queries the Infracost Cloud API for pricing lookups. A self-hosted pricing API is available for air-gapped environments.
Yes. Infracost integrates with GitHub, GitLab, Azure DevOps, and Bitbucket. In CI/CD, run infracost comment to post a cost diff summary directly on the pull request for reviewers to see.
Yes. Infracost works with both Terraform and OpenTofu. It reads the plan file output, which is compatible between both tools.
Infracost CLI is open source and free for individual use. Infracost Cloud (the SaaS dashboard with team features, governance policies, and cost tracking) has a free tier and paid plans for larger teams.
引用来源 (3)
- Infracost GitHub— Infracost cloud cost estimates for Terraform
- Infracost Docs— Infracost documentation and CI/CD integration
- Terraform Docs— Terraform infrastructure as code
讨论
相关资产
Cloud Custodian — Cloud Security & Cost Governance Rules Engine
A YAML-based rules engine for managing cloud resources across AWS, Azure, and GCP. Cloud Custodian enforces security policies, optimizes costs, and ensures compliance through automated actions on non-compliant resources.
Codeburn — AI Coding Cost Observability Dashboard
Codeburn is an interactive terminal dashboard that tracks token usage and costs across Claude Code, Codex, and Cursor, helping you understand where your AI coding budget goes.
Fluentd — Unified Logging Layer for Cloud-Native Infrastructure
Fluentd is a CNCF-graduated open-source data collector that unifies log collection and routing. With 1000+ plugins, it connects any source to any destination — the standard log layer for Kubernetes alongside Fluent Bit.
Komiser — Open-Source Cloud Cost and Resource Inspector
A self-hosted dashboard that scans AWS, GCP, Azure, and other cloud providers to visualize resources, identify cost optimization opportunities, and enforce governance policies.