One of my earliest questions was “what do things actually cost?” 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
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.
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").
For those line items, they've set aside several special columns.
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.
source - Investopedia
Amortization in our case means - we paid a lot, say $360,000 upfront for a 3 year reservation, but since we're using that over a 3 year period, our 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 amount that you paid upfront, aka the upfront fee
- The amount that you didn't pay upfront, aka the recurring fee
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 the term. 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.
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 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 elsewhere - 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
- Those same costs allocated down into the usage line items that benefit from them. And finally,
- 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.
- + recurringFeeForUsage.
- = effectiveCost This is the true cost of that resource (according to AWS' daily amortization schedule).
WHEN line_item_type = 'DiscountedUsage' THEN reservation_effective_cost
The same basic logic applies to Savings Plans, but we can get into the nuances here in the future.
WHEN line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_effective_cost
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.