AWS CLI vs Console - Cost Explorer

Viewed 1612

I'm finding that the AWS Cost Explorer Console and the AWS CLI Cost Explorer are giving two separate numbers. Any reason as to why this is happening?

For example: From my console, you can see my total for Cloudtrail is $72.66

enter image description here

However, when I put these same exact metrics for CLI, my total is $72.04

enter image description here

I know this doesn't seem like a big difference, I'm only using Cloudtrail as an example, but some of my pricier services have bigger discrepancies. Is there a reason why this is the case / can something be done to make the console and CLI have matching monthly costs?

1 Answers

As per the AWS CLI Command Reference, you have to add 1 extra day on your end date. So in your case, you need to get the report for the month of April (from 2020-04-01 to 2020-04-30). Now you have to add an additional 1 day to end date which will be 2020-05-01.

Sets the start and end dates for retrieving AWS costs. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01 , then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01

So your time period argument will be like --time-period Start=2020-04-01,End=2020-05-01

Related