CostGuard CLI
Cloud cost analysis tool for Terraform. Get cost estimates before deploying infrastructure.
Installation
pip install git+https://github.com/buddypracticerepo1-stack/costguard-cli.git
Quick Start
# Configure API key
costguard configure --api-key YOUR_API_KEY
# Analyze a single project
costguard breakdown --path ./terraform
# Analyze multiple projects with config file
costguard breakdown --config costguard.yml
# Output as JSON
costguard breakdown --path ./terraform --format json
# Output for GitHub PR comment
costguard breakdown --config costguard.yml --format github-comment --out comment.md
Configuration
Create a costguard.yml in your repository root:
version: 1
projects:
- path: infrastructure/aws
name: AWS Production
- path: infrastructure/gcp
name: GCP Production
- path: infrastructure/azure
name: Azure Production
thresholds:
warn_monthly_cost: 1000
fail_monthly_cost: 10000
output:
format: table
show_resources: true
Project Options
| Field | Required | Description |
|---|---|---|
path |
Yes | Path to Terraform directory |
name |
No | Display name (defaults to path) |
terraform_var_files |
No | List of .tfvars files to use |
terraform_vars |
No | Inline Terraform variables (key-value) |
terraform_workspace |
No | Terraform workspace name |
usage_file |
No | Path to usage file for usage-based pricing |
skip |
No | Skip this project (default: false) |
Example with all options:
projects:
- path: infrastructure/aws
name: AWS Production
terraform_var_files:
- prod.tfvars
terraform_vars:
environment: production
instance_count: "3"
terraform_workspace: production
usage_file: usage/aws-usage.yml
skip: false
Commands
costguard breakdown
Analyze Terraform plans and show cost breakdown.
# Options
--path, -p Path to Terraform directory
--config, -c Path to costguard.yml
--format, -f Output format: table, json, github-comment
--out, -o Output file path
--resources Show resource breakdown (default: true)
--api-key CostGuard API key
costguard configure
Configure CLI settings.
costguard configure --api-key YOUR_KEY
costguard configure --show
costguard version
Show version information.
Environment Variables
| Variable | Description |
|---|---|
COSTGUARD_API_KEY |
API key for authentication |
COSTGUARD_API_URL |
API endpoint URL |
CI/CD Integration
GitHub Actions
- name: Install CostGuard
run: pip install git+https://github.com/buddypracticerepo1-stack/costguard-cli.git
- name: Analyze costs
env:
COSTGUARD_API_KEY: ${{ secrets.COSTGUARD_API_KEY }}
run: |
costguard breakdown --config costguard.yml --format github-comment --out comment.md
- name: Post PR comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const comment = fs.readFileSync('comment.md', 'utf8');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
GitLab CI
cost-check:
image: python:3.11
script:
- pip install git+https://github.com/buddypracticerepo1-stack/costguard-cli.git
- costguard breakdown --config costguard.yml --format json
Output Formats
Table (default)
=== CostGuard Cost Analysis ===
Total Monthly Cost: $2,861.84
Decision: [OK] ALLOW
=== Projects ===
[OK] AWS Production
Path: infrastructure/aws
Cost: $2,725.00/month
JSON
{
"status": "success",
"decision": "ALLOW",
"summary": {
"total_monthly_cost": 2861.84
},
"projects": [...]
}
GitHub Comment
Markdown formatted for PR comments with collapsible resource sections.
License
MIT License - see LICENSE file.
Metadata
Release files for costguard 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| costguard-0.2.2.tar.gz | 19.3 kB | Without provenance | Details for costguard-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| costguard-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for costguard-0.2.2-py3-none-any.whl |
Total release size: 40.5 kB
Release files / costguard-0.2.2.tar.gz
| Download URL | costguard-0.2.2.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5623b183668d7f2f963d998d8ccc6853aa3b3d86dd99bbc37b2e20c5645360c
|
|
BLAKE2b-256 checksum How to use checksums |
a1212c0ad5dee2f5985a1a109aa495d9c1d0ea91efc2cecd61c9380707347fd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / costguard-0.2.2-py3-none-any.whl
| Download URL | costguard-0.2.2-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54e0f635270af0b40378b5d1d374f930fd0683353952ee199515561f4a3b84b5
|
|
BLAKE2b-256 checksum How to use checksums |
653e082d4e730741e3b059a68b164b848e98c0f87213cfc306ea62dac6262ec1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Security for costguard 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.