Cost Guardrails 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 cost-guardrails
Quick Start
# Set your API key
export COST_GUARDRAILS_API_KEY="your-api-key"
# Validate costs
cost-guardrails --plan plan.json --budget-code CS-FY2026-BU105-M03 --post-comment
Configuration
| Env Variable | Description | Required |
|---|---|---|
COST_GUARDRAILS_API_KEY |
API authentication key | Yes |
COST_GUARDRAILS_BUDGET_CODE |
Budget code for validation (use --skip-budget for pricing-only) |
No |
COST_GUARDRAILS_TAG |
Tag to identify this comment (e.g. production, staging) | No |
API URL is built-in. Set
COST_GUARDRAILS_API_URLonly for custom deployments.
CI/CD Integration
Azure DevOps (Extension)
Install the Cost Guardrails extension from the VS Marketplace, then use the native task:
- task: Cost Guardrails@1
inputs:
planPath: plan.json
budgetCode: $(COST_GUARDRAILS_BUDGET_CODE)
env:
COST_GUARDRAILS_API_KEY: $(COST_GUARDRAILS_API_KEY)
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
GitHub Actions
- uses: skyxops-io/costguard-action@v1
with:
plan-path: plan.json
api-key: ${{ secrets.COST_GUARDRAILS_API_KEY }}
budget-code: ${{ secrets.COST_GUARDRAILS_BUDGET_CODE }}
GitLab CI
include:
- remote: 'https://gitlab.com/skyxops-io/cost-guardrails-templates/-/raw/v1/gitlab/cost-guardrails.yml'
cost-guardrails:
extends: .cost-guardrails-review
needs: [terraform-plan]
Any CI/CD Platform
- script: |
pip install -q cost-guardrails
cost-guardrails --plan plan.json --post-comment
env:
COST_GUARDRAILS_API_KEY: $(COST_GUARDRAILS_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:
cost-guardrails --plan prod/plan.json --tag production --post-comment
cost-guardrails --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: COST_GUARDRAILS_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 Cost Guardrails 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 (Cost Guardrails@1 task) |
| GitHub Actions | Composite action (costguard-action@v1) |
| GitLab CI | Remote template (include: remote:) |
| Generic CI/CD | Raw CLI for any platform |
Metadata
Release files for cost-guardrails 2.7.5
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 |
|---|---|---|---|---|
| cost_guardrails-2.7.5.tar.gz | 52.8 kB | Without provenance | Details for cost_guardrails-2.7.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cost_guardrails-2.7.5-py3-none-any.whl | Python 3 | none | any | Details for cost_guardrails-2.7.5-py3-none-any.whl |
Total release size: 93.7 kB
Release files / cost_guardrails-2.7.5.tar.gz
| Download URL | cost_guardrails-2.7.5.tar.gz |
|---|---|
| Size | 52.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff786c84d7346599e245db4ed151964a64c233b6132e46a8245d1887c9a6ab30
|
|
BLAKE2b-256 checksum How to use checksums |
420c73587d69b32c945c9e639b3e4c33b3c9ec7cd98e74e20e8d3ff896eee99d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Release files / cost_guardrails-2.7.5-py3-none-any.whl
| Download URL | cost_guardrails-2.7.5-py3-none-any.whl |
|---|---|
| Size | 40.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a8f9eebb63800d0da4b2f02e49533653f66494761bf095c41f879e5986c99a9
|
|
BLAKE2b-256 checksum How to use checksums |
8862cd62eaa59ddc8777d08203649b507ccd9f62f240981de9218579c6898e29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.2
|
Security for cost-guardrails 2.7.5
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.