Cloud cost, COGS, and gross margin: getting the accounting right
Not all cloud spend is cost of goods sold, and where you draw the line moves reported gross margin by several points. Here is how to split infrastructure cost between COGS and operating expense, and why the split matters.
Quick answer
Cloud spend that is required to deliver the product to a paying customer is COGS: production compute, storage, databases, networking, egress, production observability, and support tooling. Cloud spend that supports building the product is operating expense: development and staging environments, CI runners, internal analytics, and experimentation. The split is usually 70 to 85 percent COGS for a mature SaaS. Misclassifying non-production into COGS can understate gross margin by 3 to 6 points, and moving it the other way to flatter margin is an audit risk.
Gross margin is the number investors and boards use to judge whether a software business is actually a software business. For a company whose product runs on cloud infrastructure, the largest single input into that number is the cloud bill, and the largest source of error is which parts of the bill count as cost of revenue. Get the split wrong and reported margin moves by several points in either direction.
The dividing line
The test is whether the spend is required to serve a paying customer. If a resource must exist for the product to be delivered, it is COGS. If it exists so engineers can build the next version, it is operating expense, normally research and development.
| Spend | Classification | Reasoning |
|---|---|---|
| Production compute and databases | COGS | Directly serves customer traffic |
| Production storage and egress | COGS | Delivering data to customers |
| Production observability and on-call tooling | COGS | Required to run the service |
| Dev and staging environments | Opex (R&D) | Supports building, not serving |
| CI runners and build infrastructure | Opex (R&D) | Part of development |
| Internal BI and data warehouse | Opex (G&A or R&D) | Internal decision support |
| Free tier and trial usage | Usually S&M | Customer acquisition cost |
Free tier is the interesting one. Infrastructure consumed by users who never pay is closer to a sales and marketing expense than a cost of revenue, and treating it that way both improves reported gross margin and gives a truer read on customer acquisition cost. It also forces someone to measure what the free tier actually costs, which is often a surprise.
Sizing the split
In a typical mature SaaS estate, production is 70 to 85 percent of cloud spend and non-production is 15 to 30 percent. Earlier-stage companies skew the other way: heavy development, light traffic, sometimes 40 percent non-production. If a company with a 3 million USD annual cloud bill and 12 million USD of revenue puts all of it in COGS, the infrastructure component of cost of revenue is 25 percent of revenue. Moving a correctly classified 22 percent of the bill (660,000 USD) into R&D takes it to 19.5 percent, a 5.5 point improvement in gross margin, with no change in a single deployed resource.
That is precisely why the split has to be principled and documented. Reclassifying to flatter a metric is the kind of thing auditors and diligence teams look for. Write the policy down, apply it consistently across periods, and restate prior periods if the policy changes.
Making the split measurable
The split is only defensible if the billing data supports it. That means either account or subscription separation between production and non-production, or a mandatory tag that every resource carries. Account separation is cleaner because it needs no tag hygiene and cannot drift, and it also simplifies access control. Where separation is not possible, enforce an environment tag with policy and measure untagged spend as a data-quality metric, as described in finding untagged resources and tag enforcement as code.
Shared services need a rule too. A shared Kubernetes cluster running production and staging workloads, a shared logging pipeline, or a shared network backbone should be allocated by a documented driver such as requested CPU, ingested gigabytes, or traffic share. Pick the driver once, write it down, and do not change it quarterly. The allocation methods are covered inshared cost allocation.
Amortization and commitments
Use amortized cost for COGS, not cash invoiced. A three-year reservation paid upfront in January is not a January cost of revenue; it is prepaid capacity consumed over 36 months. Amortized reporting also makes month-over-month gross margin comparable, which cash accounting does not. Most billing exports provide an amortized cost column; use it everywhere in margin reporting.
What improving margin actually requires
Once the split is correct, margin improvement comes from reducing production cost per unit of revenue, not from trimming dev environments. Dev savings are real but they land in R&D. The levers that move gross margin are commitment coverage on production compute, right-sizing production workloads, storage tiering, egress reduction, and architectural changes that lower cost per request. Track them as a margin workstream distinct from general cost reduction, because the two have different financial destinations.
Keeping new spend classified from day one
Classification decays when new infrastructure ships without tags or lands in the wrong account. Reviewing cost at the pull request stage is the cheapest point to catch it: the plan already says which account, which environment tag, and which module. C3X prices Terraform changes before merge and shows the monthly delta, which makes an untagged or misplaced production resource visible during review rather than during the quarterly margin close. See the resource catalog for how individual services are priced.
FAQ
Which cloud costs count as COGS?
Spend required to deliver the product to a paying customer: production compute, databases, storage, networking and egress, production observability and on-call tooling, and third-party services in the serving path. Development and staging environments, CI and build infrastructure, and internal analytics are operating expense, normally research and development, because they support building the product rather than serving it.
How should free tier infrastructure cost be classified?
Usually as sales and marketing rather than cost of revenue, since it is consumed by users who are not paying and exists to acquire customers. Classifying it that way both reflects its economic purpose and produces a truer customer acquisition cost. It also forces the organization to measure what the free tier actually costs, which is frequently larger than assumed.
How much does the COGS split change reported gross margin?
Materially. For a company with 3 million USD of cloud spend on 12 million USD of revenue, moving a correctly classified 22 percent of the bill from cost of revenue into R&D improves gross margin by about 5.5 points with no infrastructure change at all. That leverage is exactly why the policy must be documented, applied consistently, and restated if it changes.
Should COGS use amortized or invoiced cloud cost?
Amortized. An upfront reservation payment is prepaid capacity consumed over the commitment term, not a cost of revenue in the month it was charged. Amortized cost also makes month-over-month gross margin comparable, which cash-basis invoiced cost does not. Most billing exports include an amortized column that should be used throughout margin reporting.
How do I allocate shared infrastructure between COGS and opex?
Choose a documented driver and apply it consistently: requested CPU and memory for a shared cluster, ingested gigabytes for a shared logging pipeline, traffic share for shared networking. Write the driver down once and avoid changing it between periods, since a changed allocation basis moves gross margin without anything real changing in the estate.
How does C3X help keep the COGS split accurate?
The split decays when new infrastructure ships untagged or into the wrong account. C3X prices Terraform changes before merge and reports the monthly cost delta, so the account, environment tag, and module behind new spend are visible during code review rather than at the quarterly close. Catching a misclassified production resource in the pull request costs minutes; catching it in a margin restatement costs far more.
What to do next
Keep production and non-production spend classified from the first commit. C3X prices Terraform in the pull request. Start with the quickstart.
Share this post
Try C3X on your own Terraform
Free and open source. No API key required. One command to install, one command to estimate.