sofe 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sofe-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,374 @@
1
+ Metadata-Version: 2.4
2
+ Name: sofe
3
+ Version: 0.1.0
4
+ Summary: Stairway Open FinOps Engine — FinOps Policies as Code for AWS
5
+ Author-email: Carlos Cortez <carlos@cortez.cloud>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/breakingthecloud/sofe
8
+ Project-URL: Repository, https://github.com/breakingthecloud/sofe
9
+ Project-URL: Issues, https://github.com/breakingthecloud/sofe/issues
10
+ Keywords: finops,aws,cloud-governance,policy-as-code,cost-optimization
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: System :: Systems Administration
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: boto3>=1.34
21
+ Requires-Dist: pydantic>=2.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: click>=8.0
24
+ Requires-Dist: rich>=13.0
25
+
26
+ # 🏗️ SOFE — Stairway Open FinOps Engine
27
+
28
+ **FinOps Policies as Code for AWS.**
29
+
30
+ SOFE evaluates declarative YAML policies against live AWS infrastructure and produces actionable findings — idle resources, missing tags, governance violations, and cost savings opportunities.
31
+
32
+ ```bash
33
+ sofe evaluate --policies ./policies/ --profile production
34
+ ```
35
+
36
+ ```
37
+ ────────────────────────────────────────────────────────────────────────────────
38
+ Severity Policy Resource Message
39
+ ────────────────────────────────────────────────────────────────────────────────
40
+ 🟠 high no-idle-ec2 i-0abc123def avg_cpu = 2.1% (threshold: <5%)
41
+ 🟡 medium require-cost-tags i-0def456ghi missing: costCenter, owner
42
+ 🟡 medium no-unattached-ebs vol-789abc 180 days old, 500GB
43
+ ────────────────────────────────────────────────────────────────────────────────
44
+ Summary: 3 findings | Potential savings: $365.00/mo
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Why SOFE?
50
+
51
+ ### The Problem
52
+
53
+ Teams today manage cloud costs **reactively** — they see the bill spike, panic, then scramble to find what changed. Existing tools either:
54
+
55
+ - **Alert on total spend** (AWS Budgets) — no root cause, no policy enforcement
56
+ - **Scan for security** (Prowler, ScoutSuite) — not cost-focused
57
+ - **Estimate costs** (Infracost) — pre-deploy only, no runtime enforcement
58
+ - **Lock you in** (Sentinel/HCP) — vendor-specific, not portable
59
+
60
+ **No tool does:** declarative cost+governance policies that evaluate against **live** infrastructure and produce findings with dollar-amount savings.
61
+
62
+ ### The Solution
63
+
64
+ SOFE fills this gap:
65
+
66
+ ```yaml
67
+ # policies/no-idle-production.yaml
68
+ apiVersion: sofe/v1
69
+ kind: Policy
70
+ metadata:
71
+ name: no-idle-production
72
+ description: "Flag idle EC2 in production (< 5% CPU for 30 days)"
73
+ spec:
74
+ scope:
75
+ environments: [production]
76
+ resource_types: [aws.ec2]
77
+ rule:
78
+ metric: avg_cpu_utilization
79
+ period: 30d
80
+ operator: "<"
81
+ threshold: 5
82
+ severity: high
83
+ actions:
84
+ - type: recommend
85
+ suggestion: "Rightsize or terminate"
86
+ estimated_savings: calc
87
+ ```
88
+
89
+ Write a policy once. Run it daily. Get findings with savings.
90
+
91
+ ---
92
+
93
+ ## Who Should Use SOFE?
94
+
95
+ | Role | Why SOFE matters |
96
+ |------|-----------------|
97
+ | **Cloud/DevOps Engineers** | Automate governance checks in CI/CD. `sofe evaluate --fail-on high` blocks deploys that violate cost policies. |
98
+ | **FinOps Practitioners** | Define cost optimization rules as code. Track compliance across accounts. Quantify waste. |
99
+ | **Platform Engineers** | Enforce tagging standards, idle resource cleanup, and architecture best practices at scale. |
100
+ | **CTOs / Engineering Managers** | Visibility into cloud waste without manual audits. "We save $X/month because of these policies." |
101
+ | **AWS Partners / Consultants** | Deliver FinOps assessments faster with repeatable, auditable policy evaluations. |
102
+
103
+ ---
104
+
105
+ ## Why SOFE is Key for FinOps + Governance
106
+
107
+ ### 1. FinOps: Cost Optimization as Code
108
+
109
+ Traditional FinOps is manual: someone opens Cost Explorer, finds waste, creates a ticket. SOFE automates this:
110
+
111
+ ```
112
+ Write policy → sofe evaluate → findings with $ savings → action
113
+ ```
114
+
115
+ Every policy produces **quantified savings**: "$340/mo if you terminate this idle instance."
116
+
117
+ ### 2. Cloud Governance: Policies that Actually Enforce
118
+
119
+ Tags, encryption, public access, budget limits — every team has rules but no enforcement. SOFE makes them executable:
120
+
121
+ ```yaml
122
+ - require-cost-tags → "All resources must have owner + costCenter"
123
+ - s3-encryption-required → "All S3 buckets must have encryption enabled"
124
+ - no-public-without-waf → "No public-facing resource without WAF"
125
+ ```
126
+
127
+ Not just documentation. Actual enforcement in CI/CD.
128
+
129
+ ### 3. DevOps: Shift-Left Cost Awareness
130
+
131
+ Add `sofe evaluate --fail-on high` to your GitHub Action or CI pipeline. Developers see cost violations **before** merge, not after the bill arrives.
132
+
133
+ ### 4. BYaML Integration: Architecture-Aware FinOps
134
+
135
+ SOFE uses [BYaML](https://byaml.org) component types (`aws.ec2`, `aws.s3`, etc.) — the same type system used for architecture governance. This means:
136
+
137
+ - Policies reference the same types as your architecture definitions
138
+ - Findings map directly to BYaML components
139
+ - Cost data correlates with architecture versions
140
+
141
+ ---
142
+
143
+ ## Quick Start
144
+
145
+ ### Install
146
+
147
+ ```bash
148
+ pip install sofe
149
+ ```
150
+
151
+ ### Write Your First Policy
152
+
153
+ ```yaml
154
+ # policies/require-tags.yaml
155
+ apiVersion: sofe/v1
156
+ kind: Policy
157
+ metadata:
158
+ name: require-cost-tags
159
+ description: "All resources must have owner and costCenter tags"
160
+ spec:
161
+ scope:
162
+ resource_types: [aws.ec2, aws.rds, aws.s3]
163
+ rule:
164
+ metric: has_tag:owner
165
+ operator: "=="
166
+ threshold: 0
167
+ severity: medium
168
+ actions:
169
+ - type: finding
170
+ ```
171
+
172
+ ### Validate
173
+
174
+ ```bash
175
+ sofe validate --policies ./policies/
176
+ ```
177
+
178
+ ### Evaluate
179
+
180
+ ```bash
181
+ # Against real AWS (uses your AWS profile)
182
+ sofe evaluate --policies ./policies/ --profile production
183
+
184
+ # Output as JSON (for automation)
185
+ sofe evaluate --policies ./policies/ --format json > findings.json
186
+
187
+ # CI/CD mode (exit code 1 if high/critical found)
188
+ sofe evaluate --policies ./policies/ --fail-on high
189
+ ```
190
+
191
+ ---
192
+
193
+ ## How It Works
194
+
195
+ ```
196
+ ┌─────────────────┐ ┌──────────────┐ ┌──────────────────────┐
197
+ │ Policy Loader │ │ Collectors │ │ Evaluation Engine │
198
+ │ │ │ │ │ │
199
+ │ Reads YAML │────▶│ AWS APIs: │────▶│ For each policy: │
200
+ │ Validates │ │ EC2, RDS │ │ match scope → │
201
+ │ schema │ │ S3, Lambda │ │ evaluate condition → │
202
+ │ │ │ CloudWatch │ │ if violated → │
203
+ └─────────────────┘ └──────────────┘ │ generate finding │
204
+ └──────────┬───────────┘
205
+
206
+ ┌─────────▼─────────┐
207
+ │ Output │
208
+ │ • Table (CLI) │
209
+ │ • JSON (CI/CD) │
210
+ │ • Markdown (PRs) │
211
+ └────────────────────┘
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Supported Metrics
217
+
218
+ | Metric | Source | Resources |
219
+ |--------|--------|-----------|
220
+ | `avg_cpu_utilization` | CloudWatch (30d avg) | EC2, RDS |
221
+ | `monthly_cost` | Cost Explorer | All |
222
+ | `running_days` | LaunchTime | EC2, RDS |
223
+ | `has_tag:{key}` | Tags API | All |
224
+ | `storage_used_gb` | CloudWatch | S3, EBS |
225
+ | `connections` | CloudWatch | RDS |
226
+ | `invocations` | CloudWatch | Lambda |
227
+
228
+ ---
229
+
230
+ ## Pre-Built Policies
231
+
232
+ | Policy | Type | Severity |
233
+ |--------|------|----------|
234
+ | `no-idle-ec2` | Cost Optimization | high |
235
+ | `no-idle-rds` | Cost Optimization | high |
236
+ | `require-cost-tags` | Governance | medium |
237
+ | `no-oversized-staging` | Cost Optimization | high |
238
+ | `s3-lifecycle-required` | Storage | medium |
239
+ | `s3-encryption-required` | Security/Cost | high |
240
+ | `no-unattached-ebs` | Storage | medium |
241
+ | `no-old-snapshots` | Storage | low |
242
+ | `budget-exceeded` | Budget | critical |
243
+ | `no-public-without-waf` | Security/Cost | high |
244
+
245
+ ---
246
+
247
+ ## CI/CD Integration
248
+
249
+ ### GitHub Actions
250
+
251
+ ```yaml
252
+ - name: FinOps Policy Check
253
+ run: |
254
+ pip install sofe
255
+ sofe evaluate --policies ./policies/ --fail-on high --format json > findings.json
256
+ ```
257
+
258
+ ### Exit Codes
259
+
260
+ | Code | Meaning |
261
+ |:----:|---------|
262
+ | 0 | No violations (or below `--fail-on` threshold) |
263
+ | 1 | Violations found at or above `--fail-on` severity |
264
+
265
+ ---
266
+
267
+ ## Comparison
268
+
269
+ | Tool | Cost Policies | Live Eval | Savings Calc | CI/CD | Open Source |
270
+ |------|:---:|:---:|:---:|:---:|:---:|
271
+ | **SOFE** | ✅ | ✅ | ✅ | ✅ | ✅ |
272
+ | AWS Budgets | ❌ (alerts only) | ❌ | ❌ | ❌ | ❌ |
273
+ | Infracost | 🟡 (pre-deploy) | ❌ | ✅ | ✅ | ✅ |
274
+ | OPA/Rego | ✅ (security) | ❌ | ❌ | ✅ | ✅ |
275
+ | Sentinel | ✅ | ❌ | ❌ | ✅ | ❌ (HCP only) |
276
+ | Prowler | ❌ (security only) | ✅ | ❌ | ✅ | ✅ |
277
+
278
+ ---
279
+
280
+ ## Ecosystem: Competitors & Complementary Tools
281
+
282
+ ### Competitors (overlap with SOFE)
283
+
284
+ | Tool | Type | What it does | How SOFE differs |
285
+ |------|------|-------------|-----------------|
286
+ | **OPA / Rego** | OSS | General policy engine (security-focused) | SOFE is cost/FinOps-focused with savings calculations. OPA doesn't calculate $. |
287
+ | **HashiCorp Sentinel** | Proprietary | Policy-as-code for Terraform | Locked to HCP/Terraform Cloud. SOFE is runtime (evaluates live infra, not just plans). |
288
+ | **Infracost** | OSS | Cost estimation pre-deploy | Pre-deploy only. SOFE evaluates running infra + historical drift. Complementary. |
289
+ | **AWS Config Rules** | AWS Native | Compliance rules on AWS resources | Limited to AWS, no cost focus, no CI/CD output, no portability. |
290
+ | **Prowler** | OSS | Security & compliance scanning | Security-focused (CIS, PCI-DSS). Doesn't calculate cost savings or enforce FinOps. |
291
+ | **Checkov** | OSS | IaC static analysis (Terraform, CF) | Pre-deploy only (scans .tf files). SOFE scans live resources. |
292
+ | **Cloud Custodian** | OSS | Policy engine for cloud resources | Closest competitor. Actions (stop/terminate) built-in. SOFE is lighter, YAML-first, FinOps-focused. |
293
+ | **Kubecost** | OSS/Paid | Kubernetes cost monitoring | K8s only. SOFE covers all AWS services. |
294
+ | **Vantage** | SaaS | FinOps dashboard + alerts | Dashboard, not policy engine. No CI/CD. No custom rules. |
295
+ | **CloudZero** | SaaS | Cost intelligence platform | Enterprise SaaS ($$$). No self-hosted. No policies-as-code. |
296
+ | **Spot.io / NetApp** | SaaS | Cloud optimization + autoscaling | Optimization execution, not policy definition. Complementary. |
297
+ | **Apptio Cloudability** | SaaS | Enterprise FinOps platform | Enterprise-only, expensive. No CI/CD integration. No code-first approach. |
298
+ | **nOps** | SaaS | AWS cost optimization + scheduling | Automation focus. No declarative policies. |
299
+ | **CAST AI** | SaaS | K8s cost optimization | K8s-only autoscaling. Not a policy engine. |
300
+
301
+ ### Complementary Tools (use alongside SOFE)
302
+
303
+ | Tool | How it complements SOFE |
304
+ |------|------------------------|
305
+ | **Infracost** | Pre-deploy cost estimation → SOFE catches what slipped through post-deploy |
306
+ | **Terraform / OpenTofu** | Defines infra → SOFE evaluates if running infra matches cost policies |
307
+ | **AWS Cost Explorer** | Data source → SOFE collectors fetch from it |
308
+ | **CloudWatch** | Metrics source → SOFE uses CPU, connections, invocations |
309
+ | **Steampipe** | SQL-based cloud inventory → could be alternate data source for SOFE |
310
+ | **Prometheus + Grafana** | Monitoring → SOFE could consume Prometheus metrics (future) |
311
+ | **BYaML** | Architecture definitions → SOFE policies use same type system |
312
+ | **byaml-finops-mcp** | MCP tools for AI assistants → SOFE findings feed into AI reasoning |
313
+ | **FinOptix** | AI model for FinOps → explains SOFE findings in natural language |
314
+ | **GitHub Actions / GitLab CI** | CI/CD → SOFE runs as pipeline step with `--fail-on` |
315
+ | **Slack / PagerDuty** | Notifications → SOFE can webhook findings (future) |
316
+ | **Neo4j** | Graph DB → SOFE findings + BYaML relationships = cost propagation graph (future) |
317
+
318
+ ### The SOFE Position
319
+
320
+ ```
321
+ ┌─────────────────────────────────────────────────────────────────┐
322
+ │ Cloud Cost Lifecycle │
323
+ ├─────────────┬──────────────┬──────────────────┬─────────────────┤
324
+ │ PLAN │ DEPLOY │ RUN │ OPTIMIZE │
325
+ │ │ │ │ │
326
+ │ Infracost │ Sentinel │ ★ SOFE ★ │ Spot.io │
327
+ │ Checkov │ OPA/Rego │ Cloud Custodian │ CAST AI │
328
+ │ │ Checkov │ AWS Config │ nOps │
329
+ │ │ │ Prowler │ Kubecost │
330
+ ├─────────────┴──────────────┴──────────────────┴─────────────────┤
331
+ │ VISIBILITY: Vantage, CloudZero, Apptio, AWS Cost Explorer │
332
+ └─────────────────────────────────────────────────────────────────┘
333
+
334
+ SOFE lives in the RUN phase: evaluate LIVE infrastructure against
335
+ declarative FinOps policies. Produce findings with dollar savings.
336
+ ```
337
+
338
+ ### Why SOFE vs Cloud Custodian?
339
+
340
+ Cloud Custodian is the closest open source alternative. Key differences:
341
+
342
+ | | SOFE | Cloud Custodian |
343
+ |--|------|----------------|
344
+ | **Focus** | FinOps + cost governance | Security + compliance + ops |
345
+ | **Policy format** | Clean YAML (Pydantic-validated) | Complex YAML with filters/actions DSL |
346
+ | **Savings calculation** | Built-in ($ per finding) | Not included |
347
+ | **BYaML integration** | Native (same type system) | None |
348
+ | **AI reasoning** | FinOptix integration (future) | None |
349
+ | **CI/CD** | `--fail-on` exit code | Requires wrapper |
350
+ | **Scope** | AWS first, multi-cloud future | AWS + Azure + GCP |
351
+ | **Maturity** | New (2026) | Mature (2016+, Capital One) |
352
+
353
+ SOFE is opinionated toward **FinOps** — every finding has a dollar amount. Cloud Custodian is a general-purpose policy engine that happens to work on cloud resources.
354
+
355
+ ---
356
+
357
+ ## License
358
+
359
+ Apache 2.0 — free to use, modify, and distribute.
360
+
361
+ ---
362
+
363
+ ## Contributing
364
+
365
+ 1. Fork the repo
366
+ 2. Add a policy to `policies/` or a collector to `sofe/collectors/`
367
+ 3. Submit a PR
368
+
369
+ ---
370
+
371
+ ## Built by
372
+
373
+ [Carlos Cortez](https://cortez.cloud) — AWS Community Hero, CTO @ BWIT Solutions.
374
+ Part of the [BYaML](https://byaml.org) ecosystem for cloud architecture governance.