Metadata-Version: 2.4
Name: costguard
Version: 0.2.2
Summary: CostGuard CLI - Cloud Cost Analysis Tool
Author-email: SKYXOPS <support@skyxops.com>
License: MIT
Project-URL: Homepage, https://github.com/skyxops/costguard-cli
Project-URL: Documentation, https://docs.costguard.io
Project-URL: Repository, https://github.com/skyxops/costguard-cli
Project-URL: Issues, https://github.com/skyxops/costguard-cli/issues
Keywords: terraform,cloud,cost,aws,gcp,azure,finops
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: typer>=0.9.0
Requires-Dist: rich>=13.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: requests>=2.28.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"

# CostGuard CLI

Cloud cost analysis tool for Terraform. Get cost estimates before deploying infrastructure.

## Installation

```bash
pip install git+https://github.com/buddypracticerepo1-stack/costguard-cli.git
```

## Quick Start

```bash
# Configure API key
costguard configure --api-key YOUR_API_KEY

# Analyze a single project
costguard breakdown --path ./terraform

# Analyze multiple projects with config file
costguard breakdown --config costguard.yml

# Output as JSON
costguard breakdown --path ./terraform --format json

# Output for GitHub PR comment
costguard breakdown --config costguard.yml --format github-comment --out comment.md
```

## Configuration

Create a `costguard.yml` in your repository root:

```yaml
version: 1

projects:
  - path: infrastructure/aws
    name: AWS Production

  - path: infrastructure/gcp
    name: GCP Production

  - path: infrastructure/azure
    name: Azure Production

thresholds:
  warn_monthly_cost: 1000
  fail_monthly_cost: 10000

output:
  format: table
  show_resources: true
```

### Project Options

| Field | Required | Description |
|-------|----------|-------------|
| `path` | Yes | Path to Terraform directory |
| `name` | No | Display name (defaults to path) |
| `terraform_var_files` | No | List of .tfvars files to use |
| `terraform_vars` | No | Inline Terraform variables (key-value) |
| `terraform_workspace` | No | Terraform workspace name |
| `usage_file` | No | Path to usage file for usage-based pricing |
| `skip` | No | Skip this project (default: false) |

**Example with all options:**
```yaml
projects:
  - path: infrastructure/aws
    name: AWS Production
    terraform_var_files:
      - prod.tfvars
    terraform_vars:
      environment: production
      instance_count: "3"
    terraform_workspace: production
    usage_file: usage/aws-usage.yml
    skip: false
```

## Commands

### `costguard breakdown`

Analyze Terraform plans and show cost breakdown.

```bash
# Options
--path, -p       Path to Terraform directory
--config, -c     Path to costguard.yml
--format, -f     Output format: table, json, github-comment
--out, -o        Output file path
--resources      Show resource breakdown (default: true)
--api-key        CostGuard API key
```

### `costguard configure`

Configure CLI settings.

```bash
costguard configure --api-key YOUR_KEY
costguard configure --show
```

### `costguard version`

Show version information.

## Environment Variables

| Variable | Description |
|----------|-------------|
| `COSTGUARD_API_KEY` | API key for authentication |
| `COSTGUARD_API_URL` | API endpoint URL |

## CI/CD Integration

### GitHub Actions

```yaml
- name: Install CostGuard
  run: pip install git+https://github.com/buddypracticerepo1-stack/costguard-cli.git

- name: Analyze costs
  env:
    COSTGUARD_API_KEY: ${{ secrets.COSTGUARD_API_KEY }}
  run: |
    costguard breakdown --config costguard.yml --format github-comment --out comment.md

- name: Post PR comment
  uses: actions/github-script@v7
  with:
    script: |
      const fs = require('fs');
      const comment = fs.readFileSync('comment.md', 'utf8');
      github.rest.issues.createComment({
        owner: context.repo.owner,
        repo: context.repo.repo,
        issue_number: context.issue.number,
        body: comment
      });
```

### GitLab CI

```yaml
cost-check:
  image: python:3.11
  script:
    - pip install git+https://github.com/buddypracticerepo1-stack/costguard-cli.git
    - costguard breakdown --config costguard.yml --format json
```

## Output Formats

### Table (default)
```
  === CostGuard Cost Analysis ===

  Total Monthly Cost: $2,861.84
  Decision: [OK] ALLOW

  === Projects ===

  [OK] AWS Production
     Path: infrastructure/aws
     Cost: $2,725.00/month
```

### JSON
```json
{
  "status": "success",
  "decision": "ALLOW",
  "summary": {
    "total_monthly_cost": 2861.84
  },
  "projects": [...]
}
```

### GitHub Comment

Markdown formatted for PR comments with collapsible resource sections.

## License

MIT License - see LICENSE file.
