beware of strange bug in cost explorer API

this weird (and dangerous) bug in the cost explorer API made me question my sanity for a long time until I saw it clearly reproduced against multiple accounts and services.

If you have more than one metric in your call, say for instance UnblendedCost and NetUnblendedCost, they will display the same number even if they shouldn’t have the same number.

If you make the same call with just one of the metrics, UnblendedCost will show as the same correct number, but NetUnblendedCost will now be a different, correct number.

One of my specific examples looks like this:

aws ce get-cost-and-usage  \
--time-period Start=2025-02-01,End=2025-03-01 \
--granularity MONTHLY \
--metrics UnblendedCost NetUnblendedCost \
--filter '{"And": [{"Dimensions":{"Key":"SERVICE","Values":["Amazon Elastic Compute Cloud - Compute"]}},{"Dimensions": {"Key": "RECORD_TYPE", "Values": ["Usage"]}}]}' \
--output json

vs.

aws ce get-cost-and-usage \
--time-period Start=2025-02-01,End=2025-03-01 \
--granularity MONTHLY \
--metrics NetUnblendedCost \
--filter '{"And": [{"Dimensions":{"Key":"SERVICE","Values":["Amazon Elastic Compute Cloud - Compute"]}},{"Dimensions": {"Key": "RECORD_TYPE", "Values": ["Usage"]}}]}' \
--output json

I’ve made AWS aware of the issue but it might take some time to get it fixed, so in the meantime, I recommend not making any calls for multiple metrics!

Thank you for sharing this

np - can you confirm it as well?

Sorry to see the trouble.

Thank you for bringing this to our team for review. If you have a case ID to share, let us know in PM. Then we’ll do what we can on our end to help.

- Ann D.

Hello,

Our team has implemented a solution and I wanted to update you on this.

If you experience any other problems, please don’t hesitate to reach out.

- Elle G.

I’ve encountered a different type of bug. I do have some credits in my account and when I query Unblended and Net Unblended costs, it is showing me the cost after accounting for Credit.