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.

Install

pip install costguard-cli

Quick Start

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_API_URL API endpoint (default: https://api.skyxops.com) No
COSTGUARD_BUDGET_CODE Budget code for validation (use --skip-budget for pricing-only) No

CI/CD Integration

GitLab CI

Required CI/CD variables:

Variable How to set Purpose
COSTGUARD_API_KEY Settings → CI/CD → Variables (masked) API auth
GITLAB_TOKEN Project/Group Access Token with api scope Post MR comments

Note: CI_JOB_TOKEN cannot post MR comments — GitLab restricts it to read-only. Create a Project Access Token (Settings → Access Tokens → api scope) or a Group Access Token for all projects in the group.

stages:
  - cost-review

costguard-review:
  stage: cost-review
  image: python:3.12-slim
  script:
    - pip install --quiet costguard-cli
    - costguard-validate --plan plan.json --post-comment
  allow_failure:
    exit_codes:
      - 2
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

GitHub Actions

Required secrets: COSTGUARD_API_KEY. GITHUB_TOKEN is auto-provided.

- name: CostGuard Validation
  env:
    COSTGUARD_API_KEY: ${{ secrets.COSTGUARD_API_KEY }}
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: |
    pip install -q costguard-cli
    costguard-validate --plan plan.json --post-comment

Azure DevOps

Required variables: COSTGUARD_API_KEY, SYSTEM_ACCESSTOKEN.

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

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

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.

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.10.tar.gz (27.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.10-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: costguard_cli-2.0.10.tar.gz
  • Upload date:
  • Size: 27.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.10.tar.gz
Algorithm Hash digest
SHA256 fbebe4d60288458d11f477646801c1d234d3b05996b2b336cf094456f02fa6a8
MD5 89805420bd141182593c8d65e7ec3d12
BLAKE2b-256 600583b1aafe28bf5876c01cdc40c8684afbc355088bb62abe3551924fedf193

See more details on using hashes here.

File details

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

File metadata

  • Download URL: costguard_cli-2.0.10-py3-none-any.whl
  • Upload date:
  • Size: 30.3 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.10-py3-none-any.whl
Algorithm Hash digest
SHA256 c66a6cedcec9b6eb9508661bfcc1abb5f5ffa563ed8194575d740bb2dac83562
MD5 bf4a8f5cfb1d4566ce9b3a0d38ae1150
BLAKE2b-256 27d2c792e9fcb5004c3348b5eb24bf71dbb91163a1ecd2e05f5577502027711c

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