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 plan against cost policies, budget limits, and guardrails — before infrastructure is deployed.

Install

pip install costguard-cli

Usage

# Validate a Terraform plan
costguard-validate --plan plan.json --format terminal

# Post results as PR/MR comment (auto-detects GitLab/GitHub/Azure DevOps)
# Idempotent: creates on first run, updates on re-push (never duplicates)
costguard-validate --plan plan.json --format markdown --post-comment

# Use cached result across pipeline stages
costguard-validate --cached costguard-result.json --format html --output-file report.html

Configuration

Option Env Variable Description
--api-url COSTGUARD_API_URL CostGuard API endpoint
--api-key COSTGUARD_API_KEY API authentication key
--budget-code COSTGUARD_BUDGET_CODE Budget code to validate against (e.g. CS-FY2026-M01)

Output Formats

Format Use Case
terminal Local development, CI logs
markdown PR/MR comments
html Executive reports, artifacts
json Machine-readable, integrations

Exit Codes

Code Decision Meaning
0 ALLOW Deployment permitted
1 BLOCK Deployment blocked by guardrails
2 WARN Deployment allowed with warnings
3 ERROR Validation could not complete

CI/CD Integration

GitLab CI

costguard:
  script:
    - pip install costguard-cli
    - terraform show -json plan.tfplan > plan.json
    - costguard-validate --plan plan.json --format terminal --post-comment
  variables:
    COSTGUARD_API_URL: $COSTGUARD_API_URL
    COSTGUARD_API_KEY: $COSTGUARD_API_KEY

GitHub Actions

- name: CostGuard Validation
  env:
    COSTGUARD_API_URL: ${{ secrets.COSTGUARD_API_URL }}
    COSTGUARD_API_KEY: ${{ secrets.COSTGUARD_API_KEY }}
  run: |
    pip install costguard-cli
    terraform show -json plan.tfplan > plan.json
    costguard-validate --plan plan.json --format terminal --post-comment

Azure DevOps

- script: |
    pip install costguard-cli
    terraform show -json plan.tfplan > plan.json
    costguard-validate --plan plan.json --format terminal --post-comment
  env:
    COSTGUARD_API_URL: $(COSTGUARD_API_URL)
    COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)

How It Works

  1. Reads plan.json (output of terraform show -json)
  2. Sends it to the CostGuard API
  3. Receives cost breakdown, policy violations, budget status, and AI recommendations
  4. Formats and displays results
  5. Exits with appropriate code so the pipeline can ALLOW, WARN, or BLOCK

No cloud credentials required — the CLI only reads the plan file. All resource details are already in the Terraform plan output.

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.0.3.tar.gz (25.6 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.0.3-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: costguard_cli-2.0.3.tar.gz
  • Upload date:
  • Size: 25.6 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.0.3.tar.gz
Algorithm Hash digest
SHA256 e62f1ffe617e41b47de721502c786101a6017681e3baa2ba1238fcabe36988b5
MD5 72514ac277863cad9d6ca66f3e4d21d7
BLAKE2b-256 d4a2943bd7ab2bc9afd1cb12d707040d670579265faa7d7345ebb65d4dd1b2e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: costguard_cli-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 28.6 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.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 72f5bb0fd990b2f3a5030633b90788fc7e663ee688cbfccb2bf5a33ffc50988c
MD5 6a30451d039e7310432be42da3ee3745
BLAKE2b-256 02a38601b9733da92969a14e9efd3a25fcd3c0ec60295f9b88366313f802f430

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