Skip to main content

SOFE Server

REST API for the SOFE FinOps Engine
Multi-tenant evaluation platform with catalog, history, and alerts.

Quick Start · Endpoints · Usage · Ecosystem

PyPI Python License FastAPI PRs


Wraps the SOFE Python engine in a FastAPI application, enabling HTTP-based evaluations.

pip install sofe sofe-server
sofe-server
# → http://localhost:8080

Quick Start

# Install
pip install sofe sofe-server

# Start server
sofe-server

# Evaluate your AWS account
curl -X POST http://localhost:8080/evaluate \
  -H "Content-Type: application/json" \
  -d '{"profile": "default"}'

Or use the Go CLI:

sofe serve    # starts sofe-server in background
sofe evaluate # calls localhost:8080/evaluate

Endpoints

Method Path Description
GET /health Health check
POST /evaluate Evaluate AWS account against policies
POST /validate Validate an Architecture Graph (BYaML v0.4 JSON)
GET /policies List all loaded policies
GET /collectors List available collectors
GET /metrics List metrics per collector
POST /connect/test Test STS AssumeRole connection
POST /billing/query Cost Explorer query through the customer role
POST /billing/organization Organization accounts and OU paths
POST /billing/dimensions Cost Explorer dimensions/tags
POST /billing/resources Resource-level costs (last 14 days)

Usage

Evaluate a different AWS account (cross-account role)

Pass the role to assume and its ExternalId. The server calls sts:AssumeRole and runs every collector with those temporary credentials, so the account behind the role is the one that gets evaluated:

curl -X POST http://localhost:8080/evaluate \
  -H "Content-Type: application/json" \
  -d '{
    "role_arn": "arn:aws:iam::123456789012:role/sofe-read-only",
    "external_id": "your-external-id"
  }'
Field Notes
role_arn IAM role ARN to assume. Takes precedence over profile.
external_id Required with role_arn (2-1224 chars: letters, digits, +=,.@:/-).

The response says what was actually read: account_id, evaluated_via (assumed_role | profile | default_credentials) and evaluated_role_arn.

Status Meaning
400 Missing/invalid role_arn or external_id, or a role is required (see below). No AWS call is made.
403 STS denied the assume: the role does not exist in that account or its trust policy ExternalId does not match.
502 STS failed for another reason.
501 The installed sofe engine is too old for role-based evaluation (upgrade sofe).

The ExternalId is never echoed in responses or logs.

Hosted deployments: require a role

By default, a request without role_arn evaluates the account of the server's own credentials (or profile) — the right behavior for self-hosted use. A hosted server that evaluates other people's accounts must never do that. Set:

SOFE_REQUIRE_ROLE=true

and any /evaluate request that does not name a role is rejected with 400 before any AWS API is called.

Billing (S116)

All /billing/* endpoints require role_arn + external_id; the server assumes the customer's sofe-read-only role with RoleSessionName=sofe-billing and never uses its own Cost Explorer permissions. Amounts are returned as USD decimal strings and every result includes cost_status (ok, partial, access_denied, not_enabled, no_data, error). The frozen contract is in sofe-platform/docs/billing-contract-v1.schema.json.

curl -X POST http://localhost:8080/billing/query \
  -H "x-sofe-internal-secret: $SOFE_INTERNAL_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "role_arn": "arn:aws:iam::111111111111:role/sofe-read-only",
    "external_id": "external-id-from-sofe",
    "from": "2026-10-01",
    "to": "2026-11-01",
    "granularity": "monthly",
    "metric": "unblended",
    "group_by": [{"Type": "DIMENSION", "Key": "SERVICE"}]
  }'

List policies

curl http://localhost:8080/policies

Docker

docker run -p 8080:8080 -v ~/.aws:/root/.aws:ro \
  ghcr.io/breakingthecloud/sofe-community:latest

Architecture

sofe-server (this repo)
    │
    │ imports
    ▼
sofe/ (engine — pip install sofe)
    │
    │ boto3
    ▼
Your AWS Account (read-only)

sofe-server is a thin wrapper — all policy evaluation logic lives in the sofe engine.

Requirements

  • Python 3.11+
  • sofe >= 0.2.0 (engine)
  • AWS credentials (profile or role)

Development

git clone https://github.com/breakingthecloud/sofe-server.git
cd sofe-server
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]" -e ../sofe/
uvicorn sofe_server.app:app --reload --port 8080

# Tests (no AWS needed: STS and the engine are faked)
pytest

Ecosystem

Project Description
sofe Python engine (collectors + policies)
sofe-cli Go CLI (19 commands, TUI)
sofe-action GitHub Action for CI/CD
platform.sofe.dev SaaS dashboard (free tier)
sofe.dev/docs Documentation (26 pages)

License

Apache 2.0 — see LICENSE.


sofe.dev · Engine · finoptix.dev

Metadata

Release files for sofe-server 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sofe-server 0.6.0
File Size Uploaded Provenance Actions
sofe_server-0.6.0.tar.gz 28.6 kB Without provenance Details for sofe_server-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sofe-server 0.6.0
File Interpreter ABI Platform Actions
sofe_server-0.6.0-py3-none-any.whl Python 3 none any Details for sofe_server-0.6.0-py3-none-any.whl

Total release size: 48.1 kB

Release files / sofe_server-0.6.0.tar.gz

Download URL sofe_server-0.6.0.tar.gz
Size 28.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ce2aa4cfc8b7d8ee237df3442be84b8f477cb153b2b7ac04da63c7a25198fbcd
BLAKE2b-256 checksum
How to use checksums
c45274fa7e48a9adc689420b638babdcb969566be1f8491c16407928f6b2bfbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / sofe_server-0.6.0-py3-none-any.whl

Download URL sofe_server-0.6.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d11d7a0eabd1b49dc1eae949926c88889865dc53f5ac7ed877bab55af7c59f40
BLAKE2b-256 checksum
How to use checksums
07f6101864b4368043b1820f2e94343fd6534f1c60627a5eea269cb9d4616e9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Security for sofe-server 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page