feat(#237): blanket resource pricing via an Infracost breakdown importer - #238
Merged
Conversation
Adds a generic path to price the static long tail without a hand-written handler + descriptor per service. `import_breakdown` ingests `infracost breakdown --format json` output and turns each costed resource into a flatOverride node whose `fixed` metrics mirror Infracost's per-component monthly costs (subresource components flattened and namespaced; free resources skipped). Prices through the engine with no catalog lookup. - pricing/sources/infracost_breakdown.py: import_breakdown + provider inference. - cli.py: `import-infracost <breakdown.json>` subcommand (YAML/--json output). - tests: importer unit tests (EC2 + EBS subresource + ElastiCache, engine round-trip) and two CLI tests. - README: "Blanket pricing for the long tail" section. This is the DP#9 escape hatch for breadth — Infracost covers everything it prices; native handlers stay for the request-path resources where the DAG derives usage from upstream flow. Prefer a handler where one exists. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #237.
What
A generic path to price the static long tail without a hand-written
ResourceTypehandler +_METRIC_DESCRIPTORSentry per service. Infracostalready encodes extract + cost components + product filters for hundreds of
resources; this ingests its
infracost breakdown --format jsonoutput and turnseach costed resource into a priced cost-model node.
This makes infra-cost-model a DAG / what-if layer on top of Infracost's pricing
library for the always-on tail — the resources otherwise forced onto hand-written
flatOverridenodes (KMS, WAF, EIP, Route53, …). Native handlers stay for therequest-path resources where the DAG derives usage from upstream flow. Per DP#9,
the import is the escape hatch, not the default: prefer a handler where one
exists.
Changes
pricing/sources/infracost_breakdown.py—import_breakdown(json) -> {address: node}. OneflatOverridenode per costed resource;costComponentsand nested
subresourcesflatten intofixed: truemetrics valued at eachcomponent's
monthlyCost(namespaced so same-named components don't collide).Free resources (no priced components) skipped; provider inferred from the
resource-type prefix.
cli.py—import-infracost <breakdown.json>(YAML default,--json).round-trip to the Infracost monthly total) + two CLI tests.
Design note
Two things block fully automatic blanket support, and this PR is honest about
both: usage derivation isn't recoverable from a resource definition (it's an
input), and AWS
usagetypepricing keys aren't mechanically derivable. Infracosthas already solved both for its supported resources, so importing its breakdown
is the highest-leverage way to get breadth. What it can't do — model a resource's
usage as a function of upstream DAG flow — is exactly what the native handlers are
for, so the two compose.
Tests
pytest— full suite green (953 passed); 12 new tests.Follow-ups (noted in the issue)