Metadata-Version: 2.4
Name: cloudbrain-cli
Version: 0.1.1
Summary: Infrastructure Cost Intelligence CLI — safe, read-only cloud cost optimization scanner for AWS and Databricks
Project-URL: Homepage, https://github.com/makebeen/cloudbrain
Project-URL: Repository, https://github.com/makebeen/cloudbrain
Project-URL: Issues, https://github.com/makebeen/cloudbrain/issues
Author-email: Abhilash <makebeen.info@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: aws,cli,cloud,cost,databricks,finops,infrastructure,optimization,scanner
Classifier: Development Status :: 3 - Alpha
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.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Requires-Dist: boto3>=1.34.0
Requires-Dist: click>=8.1.7
Requires-Dist: databricks-sdk>=0.20.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: pyyaml>=6.0.1
Requires-Dist: requests>=2.31.0
Requires-Dist: rich>=13.7.0
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == 'dev'
Requires-Dist: moto>=5.0.0; extra == 'dev'
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: responses>=0.25.0; extra == 'dev'
Requires-Dist: ruff>=0.3.0; extra == 'dev'
Requires-Dist: twine>=5.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# cloudbrain

**Infrastructure Cost Intelligence CLI** — a safe, read-only scanner that identifies cloud infrastructure waste and generates optimization recommendations.

## What it does

- Scans AWS and Databricks environments using read-only API access
- Identifies idle, underutilized, and misconfigured resources
- Estimates monthly savings potential with exact current vs recommended config
- Prioritizes recommendations by savings impact and risk level
- Scans: clusters, SQL warehouses, jobs, Unity Catalog, compute policies
- Outputs reports to terminal, JSON, or CSV

## Install

```bash
pip install cloudbrain-cli
```

## Usage

### Scan

```bash
# Scan Databricks
export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
export DATABRICKS_TOKEN="dapi..."
cloudbrain scan --provider databricks

# Scan AWS
export AWS_ACCESS_KEY_ID="your_key"
export AWS_SECRET_ACCESS_KEY="your_secret"
cloudbrain scan --provider aws

# Scan both providers
cloudbrain scan --provider aws --provider databricks

# Scan specific AWS regions
cloudbrain scan --provider aws --regions us-east-1,eu-west-1
```

### Export

After running a scan, save the report without re-scanning:

```bash
# Save as JSON (to ~/Downloads)
cloudbrain export json

# Save as CSV (to ~/Downloads)
cloudbrain export csv
```

### Commands

| Command | Description |
|---------|-------------|
| `cloudbrain scan --provider <name>` | Run a cost scan (results shown in terminal) |
| `cloudbrain export json` | Save last scan as JSON to ~/Downloads |
| `cloudbrain export csv` | Save last scan as CSV to ~/Downloads |
| `cloudbrain init` | Generate default config at ~/.cloudbrain/config.yaml |
| `cloudbrain --version` | Show version |
| `cloudbrain --help` | Show help |

## What it scans

### Databricks
| Resource | Checks |
|----------|--------|
| Clusters | Idle detection, auto-termination config, autoscaling config, oversized drivers |
| SQL Warehouses | Auto-stop config, sizing vs query rate, multi-cluster over-provisioning |
| Jobs | Failure rates, expensive jobs, long-running jobs, cost per run |
| Unity Catalog | Catalogs, schemas, Delta table optimization, external locations |
| Compute Policies | Missing policies, weak policies, clusters without policies |

### AWS
| Resource | Checks |
|----------|--------|
| EC2 | Idle instances (<5% CPU), underutilized instances, rightsizing suggestions |
| EBS | Orphaned volumes, old unattached snapshots |
| S3 | Missing lifecycle policies, infrequent access candidates |
| ELB | Load balancers with no healthy targets |
| Elastic IPs | Unassociated IPs (charged hourly) |
| NAT Gateways | Low-traffic gateways |

## Security Model

- **Read-only access only** — never modifies your infrastructure
- **No data exfiltration** — all processing happens locally on your machine
- **No database** — nothing stored except a local cache of the last scan
- **Least-privilege IAM** — requires only Describe/List/Get permissions
- **Credential safety** — credentials never written to disk or logs

## Configuration

```bash
# Generate default config
cloudbrain init

# Config location: ~/.cloudbrain/config.yaml
```

Configurable thresholds include:
- `observation_window_days` — how far back to look (default: 90)
- `cpu_idle_percent` — CPU threshold for idle classification (default: 5%)
- `cpu_underutilized_percent` — CPU threshold for rightsizing (default: 20%)
- `cluster_idle_minutes` — idle time before flagging (default: 30)
- `warehouse_low_query_rate` — queries/hour threshold (default: 5)

## Example Output

```
💰 Estimated Monthly Savings: $16,704.87
📋 Total Findings: 148 (31 with cost impact)

━━━ Actionable Findings (31) ━━━

  #1 [MEDIUM RISK] OVERSIZED WAREHOUSE — $1,460.00/mo
      SQL Warehouse 'prod-serverless-analytics-sql-warehouse'
        ├─ Size: Small | Queries: 0.0/hr
        ├─ CURRENT CONFIG: cluster_size = Small ($4.00/hr)
        ├─ RECOMMENDED: cluster_size = X-Small ($2.00/hr)
        └─ ESTIMATED SAVINGS: $1460.00/mo

  #2 [LOW RISK] IDLE CLUSTER — $903.38/mo
      Cluster 'catalog-inventory-pipeline-compute'
        ├─ State: RUNNING (idle for 60 min)
        ├─ Node type: i4i.2xlarge × 2 workers
        ├─ Current cost: $1.24/hr ($903.38/mo if always on)
        ├─ Wasted so far this idle period: $1.23
        └─ ACTION: Terminate now or set auto-termination to 30 min
```

## Requirements

- Python 3.11+
- AWS credentials (for AWS scanning) — configured via `aws configure` or environment variables
- Databricks PAT (for Databricks scanning) — generated from workspace settings

## License

MIT
