Infracost — shows infrastructure cost BEFORE apply (in PR).
Installation:
1curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh2infracost auth login
View cost:
1infracost breakdown --path .2# Output:3# Name Monthly Qty Unit Monthly Cost4# aws_instance.web5# ├─ Instance usage (on-demand, t3.micro) 730 hours $8.476# └─ root_block_device7# └─ Storage (gp3, 8 GB) 8 GB $0.808#9# TOTAL $9.27
Diff (comparison with main):
1infracost diff --path .2# Output:3# aws_instance.new (+$12.41/month)4# + Instance usage (on-demand, t3.large) 730 hours $12.41
GitHub Actions (posting in PR):
1- name: Infracost Cost Estimate2 uses: infracost/actions/setup@v33 with:4 api-key: ${{ secrets.INFRACOST_API_KEY }}56- name: Run Infracost7 run: infracost diff --path . --format json --out infracost.json89- name: Post comment10 uses: infracost/actions/comment@v311 with:12 path: infracost.json13 behavior: update
Infracost Registry: 1000+ prices for AWS, GCP, Azure, Kubernetes resources.