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 (omit 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.5.tar.gz (26.7 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.5-py3-none-any.whl (29.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: costguard_cli-2.0.5.tar.gz
  • Upload date:
  • Size: 26.7 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.5.tar.gz
Algorithm Hash digest
SHA256 1e6503899ce1a6c4dc8392339b438e049f7a1241bc829f0e29a0b97a5fae5daf
MD5 ef039dccbf4a15e0876b9174774cba53
BLAKE2b-256 e82590c987945fca61295a4d9838890e60d70d96137d96b972ebff61fa2fd434

See more details on using hashes here.

File details

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

File metadata

  • Download URL: costguard_cli-2.0.5-py3-none-any.whl
  • Upload date:
  • Size: 29.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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 db879e759a01fe40e6872192877082add83b4d42aaa16c7ef01b5eee9ffa227c
MD5 e69a3508343dbb80dbdf25b220a77162
BLAKE2b-256 38e61c4ce2c68044ca651e9570323bc1c6a1c8908d15ce4d837d6164dfa33d70

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