Repository navigation
Adding a Provider
balakrishnagatla edited this page Nov 29, 2026
·
1 revision
A provider is one class with four read-only methods. Everything else (lifecycle, correlation, MCP tools, reports, savings tracking) comes for free.
from datetime import datetime
from infralens.models import Category, Change, Finding, Severity
from infralens.providers.base import Provider
class GCPProvider(Provider):
name = "gcp"
def find_cost_savings(self) -> list[Finding]:
return [Finding(cloud="gcp", account=project, region=zone,
category=Category.SAVINGS, check="unattached_disk",
resource_type="persistent_disk", resource_id=disk.name,
title=f"{disk.size_gb} GB disk not attached",
est_monthly_cost_usd=disk.size_gb * 0.04,
evidence={"size_gb": disk.size_gb},
recommendation=f"gcloud compute disks delete {disk.name} --zone {zone}",
tags=dict(disk.labels))
for disk in ...]
def find_incidents(self) -> list[Finding]: ... # alerts, error spikes
def recent_changes(self, since: datetime) -> list[Change]: ... # audit log writes, deploys
def list_resources(self) -> list[Finding]: ... # optional: for ownership gaps
def search_logs(self, query, minutes=60, source=None): ... # optional- Read-only. Never create, modify or delete anything.
- Return
FindingandChangeobjects only, never raw SDK objects. - Fill
tagsso owner, team and env resolve and ignore rules apply. - Put the numbers an AI needs in
evidence. - Read thresholds from
self.policyand your settings fromself.options(provider_options.<name>). - Ship the minimum permissions as a file under
deploy/.
In-tree: add it to BUILTIN in src/infralens/providers/__init__.py.
Out-of-tree plugin, in your package's pyproject.toml:
[project.entry-points."infralens.providers"]
gcp = "infralens_gcp:GCPProvider"Use fakes or an emulator so tests need no credentials (see tests/test_aws.py with moto and tests/test_azure.py with fakes). Then:
pip install -e ".[aws,k8s,dev]"
pytest -q && ruff check src tests demoOpen a PR. A GCP provider is the most wanted contribution. See CONTRIBUTING.md.