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)
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.0.tar.gz (25.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.0.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: costguard_cli-2.0.0.tar.gz
  • Upload date:
  • Size: 25.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.0.0.tar.gz
Algorithm Hash digest
SHA256 5e9fe801560c1bcdc72ab989b18d8b7ccb36680d225938c07ff1c8244f3e296a
MD5 f98be0fa38ce395170cfe5b91d0d02b6
BLAKE2b-256 0863a3dad60a2659c52563f674804cfa094ad712376b659e966b6346a5a39b99

See more details on using hashes here.

File details

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

File metadata

  • Download URL: costguard_cli-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 497086442063e44061cf7acaaaabdbe237f4e30ca73ba8eba560b8c58660488e
MD5 ae19112339978deb19dfe5bd2eac793a
BLAKE2b-256 56dfba3478da90a6802cfaa3f2c2fd9f771119ddbe4851930089860d13cf4199

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