The most important columns in your AWS CUR bill – usage costs

One of my earliest questions was “what do things actually cost, segmented by their pricing model?” On demand usage was easily available in the unblended_cost column, but if I take all DiscountedUsage line items (ones that are covered by a reservation) and SUM(unblended_cost), it gives me 0. What??

This is what I learned while figuring this out.


First, the code

CASE
    WHEN line_item_type = 'DiscountedUsage' THEN reservation_effective_cost
    WHEN line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_effective_cost
    ELSE unblended_cost
END AS finops_effective_cost,

This is it. It took me a while wandering in the woods to come up with this simple little case statement. Let's dig in a bit starting at the bottom.

lineItem/UnblendedCost

The UnblendedCost is the UnblendedRate multiplied by the UsageAmount.

Gee, thanks. Look, as simply as possible – this is the first column you're going to get to know in this bill when you're first introduced into this job. If you sum this column up for the entire month, you're going to get a number that matches what the Cost Explorer says you spent that month.

This number is the number that matters for basically all usage costs except those to which a reservation or savings plan apply. That is to say – storage, data transfer, anything except those where line_item_type IN ("DiscountedUsage", "SavingsPlanCoveredUsage").

lineItem/LineItemType

For those line items, they've set aside several special columns.

reservation/EffectiveCost

Things get hairy, fast. You're 30 seconds into my first nuts and bolts post, and we're going to talk about amortization already. Amortization is actually pretty simple, as are many previously inscrutable finance terms when you learn what they mean.

Amortization basically means – your business bought something for a lot of money, and that something is going to be used over a period of time. You may have paid $360,000 upfront for a 3 year reservation, but since you're using that over a 3 year period, your business is going to be using $10,000 of that reservation a month. This is amortization. It takes the otherwise huge swings in your company's expenses (in cash basis accounting) and smooths them out a little (into accrual basis accounting). More here.

So – AWS helps you out a little with this. We'll get into the SavingsPlan and Reservation line items in a future post, but we're talking about usage line items for which a reservation is applied here.

There are two components to reservation covered usage:

The recurring fee is pretty simple – you get charged for it every day of the term of that reservation. It recurs. The upfront fee is more interesting. That's the big thing you bought at the beginning of some term. You're going to be using it for a while, and so while you could theoretically account for that giant upfront fee in the month you paid it, your Finance team is almost certainly handling it by amortizing it over the term of the reservation.

AWS helps you by taking that upfront fee and amortizing it for you as well, daily. For a 3 year reservation with an upfront payment of $360k, they will count up the number of days in that 3 years – either 1095 or 1096 if there's a leap year – and divide 360,000 by that, roughly $330/day.

Important to note – your Finance department probably does not amortize these upfront payments daily, and so your numbers for February will always be lower than theirs for January or March. This is partially why.

Now here's where it gets really fun. AWS takes that $330/day and makes it available in a couple of places. One place is in the [RIFee](reservation-details-A-AmortizedUpfrontFeeForBillingPeriod) line items in the bill. Each day you get a number of line items that pertain just to the Reservations, not the actual usage line items. These are ones where line_item_type = "RIFee". (docs) In those line items you have the amortized upfront payment for that day and that's pretty much it. The “recurring fee for usage” shows up in the usage line items that benefit from the reservation. This is a little strange to me, but the docs here seem to confirm this: the amortized upfront stuff appears in the RIFee line item, the recurring costs do not. recurringFeeForUsage docs – it only shows up in DiscountedUsage, the usage line item.

This is a lot, I know, so let's review. You have amortized upfront reservation costs available in the RIFee line items. You have those same costs allocated down into the usage line items that benefit from them. Then you also have the recurring cost for that reservation (if not fully paid upfront) that shows up in the usage line items as well (DiscountedUsage, that is).

Now, you can do it yourself but AWS takes those two columns in the DiscountedUsage line items and adds them together to arrive at what we call the “effective cost”. Effective cost is the amortized upfront cost + the recurring cost.

WHEN line_item_type = 'DiscountedUsage' THEN reservation_effective_cost

savingsPlan/savingsPlanEffectiveCost

The same basic logic applies to Savings Plans, so we can get into the nuances here in the future.

WHEN line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_effective_cost

In closing

This took me a while to figure out, so hopefully this can help make it a little bit clearer for you as you're learning your way around the CUR. This “effective cost” column is one that we use here to present the “true” cost of resources that we use for a given billing period.

#aws #inpractice