CostGuard CI/CD validation CLI — shift-left cost governance for cloud infrastructure
Project description
CostGuard CLI
Shift-left cost governance for CI/CD pipelines. One command validates your Terraform or CloudFormation plan against cost policies, budget limits, and guardrails — before infrastructure is deployed.
Note: A SKYXOPS subscription is required to use this CLI. This module can run as a standalone tool or be integrated into CI/CD pipelines.
Install
pip install costguard-cli
Quick Start
# Set your API key
export COSTGUARD_API_KEY="your-api-key"
# Validate costs
costguard-validate --plan plan.json --budget-code CS-FY2026-BU105-M03 --post-comment
Configuration
| Env Variable | Description | Required |
|---|---|---|
COSTGUARD_API_KEY |
API authentication key | Yes |
COSTGUARD_BUDGET_CODE |
Budget code for validation (use --skip-budget for pricing-only) |
No |
COSTGUARD_TAG |
Tag to identify this comment (e.g. production, staging) | No |
API URL is built-in. Set
COSTGUARD_API_URLonly for custom deployments.
CI/CD Integration
Azure DevOps (Extension)
Install the CostGuard extension from the VS Marketplace, then use the native task:
- task: CostGuard@1
inputs:
planPath: plan.json
budgetCode: $(COSTGUARD_BUDGET_CODE)
env:
COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
GitHub Actions
- uses: skyxops-io/costguard-action@v1
with:
plan-path: plan.json
api-key: ${{ secrets.COSTGUARD_API_KEY }}
budget-code: ${{ secrets.COSTGUARD_BUDGET_CODE }}
GitLab CI
include:
- remote: 'https://gitlab.com/skyxops-io/costguard-templates/-/raw/v1/gitlab/costguard.yml'
costguard:
extends: .costguard-review
needs: [terraform-plan]
Any CI/CD Platform
- script: |
pip install -q costguard-cli
costguard-validate --plan plan.json --post-comment
env:
COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)
Output Formats
| Format | Flag | Use Case |
|---|---|---|
| Terminal | --format terminal |
CI logs (default) |
| Markdown | --format markdown |
PR/MR comments |
| HTML | --format html |
Executive reports |
| JSON | --format json |
Integrations |
Exit Codes
| Code | Decision | Pipeline Effect |
|---|---|---|
| 0 | ALLOW | Continues |
| 1 | BLOCK | Stops |
| 2 | WARN | Continues (use allow_failure: exit_codes: [2]) |
| 3 | ERROR | Stops |
Multi-Environment Tags
Use --tag to post separate comments for each Terraform root or environment in a single MR/PR:
costguard-validate --plan prod/plan.json --tag production --post-comment
costguard-validate --plan staging/plan.json --tag staging --post-comment
Each tag gets its own isolated comment. Without --tag, a single comment is posted. Set via env var: COSTGUARD_TAG.
Comment Behavior
--post-comment is idempotent: creates one comment on first run, updates it on re-push. No duplicates. Works on GitLab MRs, GitHub PRs, and Azure DevOps PRs.
How It Works
- Reads plan file (Terraform
plan.jsonor CloudFormation changeset) - Sends to CostGuard API for pricing, budget validation, and guardrail checks
- Displays cost breakdown, AI recommendations, and decision
- Posts result as MR/PR comment (if
--post-comment) - Exits with decision code so the pipeline can ALLOW, WARN, or BLOCK
No cloud credentials required — the CLI only reads the plan file.
Documentation
| Doc | Description |
|---|---|
| Getting Started | Prerequisites, installation, quick start |
| CLI Reference | Complete flag and option reference |
| Architecture | Technical architecture, API flow, data model |
| Troubleshooting | Common issues across all platforms |
Integration Guides
| Platform | Guide |
|---|---|
| Azure DevOps | Native extension (CostGuard@1 task) |
| GitHub Actions | Composite action (costguard-action@v1) |
| GitLab CI | Remote template (include: remote:) |
| Generic CI/CD | Raw CLI for any platform |
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_cli-2.4.0.tar.gz.
File metadata
- Download URL: costguard_cli-2.4.0.tar.gz
- Upload date:
- Size: 37.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc8b58a3aafa1ec969b6f389b39cb0d13c370d9c408db0cd4311464f785f1934
|
|
| MD5 |
40e2a7dba6e6e7848384f1ce9075ee68
|
|
| BLAKE2b-256 |
309beadbc845cd9e6c6f324e0ed9aa664a90b85d24a47a229e7574f4c1d193a5
|
File details
Details for the file costguard_cli-2.4.0-py3-none-any.whl.
File metadata
- Download URL: costguard_cli-2.4.0-py3-none-any.whl
- Upload date:
- Size: 36.5 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 |
954c7f76ec11c748281a38fcecb954dba5cf7d2878fc1edbb88575ae828e7954
|
|
| MD5 |
89fba1618e9fa1146e3638fdeebd56be
|
|
| BLAKE2b-256 |
1be88f0b46067b562ecd14cdd9f3fa2a9aaf2573f4cefb174d62b902099c0e12
|