Skip to main content

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_URL only 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)

Full Azure DevOps Guide

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 }}

Full GitHub Actions Guide

GitLab CI

include:
  - remote: 'https://gitlab.com/skyxops-io/costguard-templates/-/raw/v1/gitlab/costguard.yml'

costguard:
  extends: .costguard-review
  needs: [terraform-plan]

Full GitLab CI Guide

Any CI/CD Platform

- script: |
    pip install -q costguard-cli
    costguard-validate --plan plan.json --post-comment
  env:
    COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)

Generic CI/CD Guide

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

  1. Reads plan file (Terraform plan.json or CloudFormation changeset)
  2. Sends to CostGuard API for pricing, budget validation, and guardrail checks
  3. Displays cost breakdown, AI recommendations, and decision
  4. Posts result as MR/PR comment (if --post-comment)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

costguard_cli-2.2.0.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

costguard_cli-2.2.0-py3-none-any.whl (35.5 kB view details)

Uploaded Python 3

File details

Details for the file costguard_cli-2.2.0.tar.gz.

File metadata

  • Download URL: costguard_cli-2.2.0.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for costguard_cli-2.2.0.tar.gz
Algorithm Hash digest
SHA256 ee7ae74c630e59441c72eab798da2baaea68a0dc1bf13d38580efb5babfe844c
MD5 81cce419cf2f0390099c18f335c5759b
BLAKE2b-256 dcf33dfc6f118527ef83d2ee3a9375ef64693d0e62dff8fb91139cc7c7a4486e

See more details on using hashes here.

File details

Details for the file costguard_cli-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: costguard_cli-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for costguard_cli-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2bc3e2ac1abfe9a1e6b897016d783906dd6b5d92f8d37d739b780e36a3938ed
MD5 14ee9cbffd811c63cfd0295e3dffd0d1
BLAKE2b-256 66f650c52fb94f7192064b0db65630decba9248da7bc60788baa6a4ee8e9e4d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page