CostGuard CLI - Cloud Cost Analysis Tool
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file costguard-0.2.1.tar.gz.
File metadata
- Download URL: costguard-0.2.1.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7f078dd3abe2bf2285c38fbeadbb1449667fbcca243573247b23d16ee82af96
|
|
| MD5 |
4c4d70f745b796fe5a6afce180770aa8
|
|
| BLAKE2b-256 |
7aaeaa6d9f0858df8f90f7c0e606d4606210b40437b67a4d3864f5dc63309442
|
File details
Details for the file costguard-0.2.1-py3-none-any.whl.
File metadata
- Download URL: costguard-0.2.1-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b8c60b797be4d6defdf6b0f3b6c87b8c6200f0a0e0a78426075407ce6ee2ea1
|
|
| MD5 |
f6ba350b6c77d28d80da3f17c0ad568f
|
|
| BLAKE2b-256 |
e4a30d51663c2c04c588fbd012f00af4aae1dba015f9c65c6e7c826bc5132b17
|