<p>yes it is, I made a lambda function that posted it to a slack channel.</p>
<p>This is the CLI reference ce = cost-explorer</p>
<p><a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ce/index.html" rel="nofollow noreferrer">https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ce/index.html</a></p>
<p>I remember there was a tricky part and if I'm not mistaken the forecast would be from today to the end of the month, so as the days passed it would decrease. When I built my version we were doing a lot of cost optimizations so it was very deceiving hahaha</p>
<p>So if you want the cost forecast to match the dashboard, you have to get the summary + the forecast. Not something super tricky, just something to watch for.</p>

CC BY-SA 4.0
2021-11-20T10:23:10.247Z
It looks like the cost explorer API can be queried for detailed usage statistics associated with arbitrary time windows. My question is specifically how to get exactly what the dashboard shows using the aws cli.
codemutation
CC BY-SA 4.0
2021-11-20T10:39:04.387Z
Also, I the cost explorer is a separate service that must be enabled. The pricing page says each cost explorer request will incur a cost.
codemutation
CC BY-SA 4.0
2021-11-20T20:42:38.537Z
sorry, I didn't make it clear. you can get the information but you will have to compose it using several API calls. Think of it like 'I want to get all the information I see in the VPC dashboard'. You will have to list the vpcs, aggregate the submets, etc. Same thing with the cost explorer, it's possible but there is no 'get-dash-stats' method, you have to compose it. That's what I meant by the monthly estimate, not even that, which is supposed to be trivial is a straightforward API call.
Magus
CC BY-SA 4.0
2021-11-19T09:48:13.993Z
2021-11-19T09:48:13.993Z
Magus
<p>The aws web console under &quot;Billing&quot; (<a href="https://console.aws.amazon.com/billing/" rel="nofollow noreferrer">https://console.aws.amazon.com/billing/</a>) shows &quot;Month-to-Date Spend by Service&quot; which breaks down costs incurred so far this month by each service that is in use by an account.</p>
<p>It also shows the &quot;Spend Summary&quot; which shows the recent monthly total incurred cost as well as this month's forecast.</p>
<p>Is there a way to retrieve this information using the AWS CLI?</p>

<aws-cli><billing>
View billing and cost management dashboard info with AWS CLI
codemutation
# View billing and cost management dashboard info with AWS CLI

(Asked by: username_0 on 2021-11-18)

The aws web console under "Billing" (<https://console.aws.amazon.com/billing/>) shows "Month-to-Date Spend by Service" which breaks down costs incurred so far this month by each service that is in use by an account.

It also shows the "Spend Summary" which shows the recent monthly total incurred cost as well as this month's forecast.

Is there a way to retrieve this information using the AWS CLI?

**Tags:** aws-cli, billing


---

## 1 answers

### Answer by username_1 on 2021-11-19. Score: 1

yes it is, I made a lambda function that posted it to a slack channel.

This is the CLI reference ce = cost-explorer

<https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ce/index.html>

I remember there was a tricky part and if I'm not mistaken the forecast would be from today to the end of the month, so as the days passed it would decrease. When I built my version we were doing a lot of cost optimizations so it was very deceiving hahaha

So if you want the cost forecast to match the dashboard, you have to get the summary + the forecast. Not something super tricky, just something to watch for.

> **Comments:**
> **username_0**: It looks like the cost explorer API can be queried for detailed usage statistics associated with arbitrary time windows. My question is specifically how to get exactly what the dashboard shows using the aws cli.  
> **username_0**: Also, I the cost explorer is a separate service that must be enabled. The pricing page says each cost explorer request will incur a cost.  
> **username_1**: sorry, I didn't make it clear. you can get the information but you will have to compose it using several API calls. Think of it like 'I want to get all the information I see in the VPC dashboard'. You will have to list the vpcs, aggregate the submets, etc. Same thing with the cost explorer, it's possible but there is no 'get-dash-stats' method, you have to compose it. That's what I meant by the monthly estimate, not even that, which is supposed to be trivial is a straightforward API call.  

---

