Pricing a Change Before You Apply It: How InfraOrcinus Estimates Cost
By Chirag Panchal · Founder & Lead Architect · · 7 min read
How InfraOrcinus puts a monthly cost on a plan before anyone approves it: live Azure retail prices where a meter is verified, a built-in estimate table everywhere else, a label on every line saying which one answered, and plan-level policy rules that can warn or block on the total or the change. Plus what is not priced yet.
Development Status & Architectural Evolution: InfraOrcinus is in active development. Architecture specifications, internal interfaces, and operational protocols described herein reflect our current engineering design and are continuously refined to make InfraOrcinus robust, resilient, and enterprise-grade.
Cloud cost is usually learned the slow way. A change is approved, applied, and a month later an invoice says what it cost. By then the question "was this worth it?" has no useful answer.
InfraOrcinus puts a number on the change while the plan is still waiting for a person. The approver sees the estimated monthly total and the change since the last estimate next to the resource counts, and a policy can stop a run that crosses a limit. This article describes how that estimate is built, which parts are live prices and which are approximations, and where it does not reach yet.
An earlier version of this article described AWS and Google Cloud price feeds, a SQL pricing catalog and sub-50-millisecond lookups. That was a design sketch, not what ships. This version describes what the code does today.
1. Where the Estimate Comes From
The estimate is computed when a plan is uploaded, from the engine-neutral plan summary (the same normalized structure that policy and the approver's screen read). Each billable resource in the plan becomes a small, provider-neutral description: a kind (virtual machine, disk, public IP, load balancer, object storage, database, NAT gateway), a region, and the size or SKU that drives the price.
For each one the resolver tries three layers in order:
- Cache. A price fetched earlier is reused for a day. Retail prices move slowly, so a day is safe, and the cache keeps a plan from calling a pricing API for every resource.
- Live provider API. Today the live source is the public Azure Retail Prices API. It needs no credentials.
- Built-in estimate table. If there is no live source for that cloud, the API is down, or the resource has no verified meter, a static table of rough on-demand prices answers.
A lookup therefore never fails outright. It degrades, and it says so.
2. Every Line Says Where Its Price Came From
Each line item records its origin (live, cache, or fallback), the source name, the unit price and unit behind the monthly figure, the region and the SKU it was quoted for. The estimate as a whole counts how many lines were priced live and how many were estimated, and lists the sources that contributed (for example azure-retail and static-estimate).
That matters more than the precision of any one number. A total built from nine live prices and one estimate is a different statement from a total built from ten guesses, and the screen tells the approver which one they are looking at.
Two details keep the estimate honest:
- Hours per month is 730, the convention the cloud providers' own calculators use, applied the same way to every hourly meter.
- A slow API cannot hold up a plan. A live lookup has an eight-second budget. If it expires, that resource falls back to the estimate table. Identical lookups in one plan (twenty identical VMs) are collapsed into one call.
3. What "Change" Means Here
Each estimate stores the previous estimate for the same environment, and the monthly change is the new total minus the previous total. It is not a per-resource diff of this plan against reality, and it is only as good as the last estimate. An environment with no earlier estimate shows its whole total as the change.
4. From a Number to a Gate
An estimate on its own is information. To make it a control, plan-level policy rules can test two values: the estimated monthly total and the monthly change. A rule has an enforcement mode:
- Advisory. The violation is shown to the approver and recorded. The run can still proceed.
- Mandatory. The violation blocks the apply, so the change cannot go forward until the plan or the policy changes.
Those rules sit beside the rest of the policy evaluation, so a cost violation appears in the same list as a missing-encryption finding, and a run that fails a mandatory rule is held at the same named human approval gate described in the approval-gate article. The cost rule does not replace the approval; it decides whether there is anything to approve.
5. What Is Not Priced Yet
Precision about limits matters more than sounding complete:
- Live prices are Azure only. AWS and Google Cloud resources are priced from the built-in estimate table, so their lines are labelled as estimates. The code is organized so another cloud's source can be added without touching the estimator, but none exists yet.
- Within Azure, only verified meters are live. Virtual machines, managed disks and public IPs are priced from the API. Other Azure resource kinds fall back to the table.
- The estimate table ignores a lot. It uses rough on-demand prices and deliberately ignores region, commitments, free tiers, tax and data transfer.
- Some plans are not priced at all. Azure Bicep and AWS CloudFormation plans list resources as "pricing not available for this resource type", so a rule on total cost only sees the priced part. Resources the estimator does not recognise are counted as unsupported and shown as such.
- It is a monthly steady-state figure. It does not model usage-based charges such as requests, egress or storage growth.
Treat the number as a guardrail for obvious mistakes (a database ten times larger than intended), not as a forecast you could reconcile to an invoice.
Summary
Cost is estimated at plan time from the normalized plan, priced through a cache, then the live Azure Retail Prices API, then a built-in table, with every line labelled by origin. The change since the previous estimate and the monthly total can feed advisory or mandatory policy rules, so a run that crosses a limit is stopped or flagged before it reaches the apply. Live pricing covers Azure virtual machines, disks and public IPs; everything else is an estimate you can see is an estimate.