steampipe-plugin-aws icon indicating copy to clipboard operation
steampipe-plugin-aws copied to clipboard

Update table aws_cost_forecast_monthly to query all accounts within organization

Open vkumbha opened this issue 2 years ago • 2 comments

I can make use of the tables aws_cost_by_record_type_monthly or aws_cost_by_account_monthly to query the actual usage of hundreds of accounts within my AWS Organizations. For example the below query gives the usage of all my accounts. I want to be able to query the forecast in addition to the actual usage. However, the forecast table aws_cost_forecast_monthly can not query the accounts across organization and is focused on only a single account. Please update the aws_cost_forecast_monthly table so that I can query the entire organization similar to other usage tables.

select account_id,
  linked_account_id,
  record_type,
  period_start,
  blended_cost_amount::numeric::money
from 
  all_aws.aws_cost_by_record_type_monthly
  where period_start>=date_trunc('month', now()) and record_type='Usage'
order by
  account_id,
  period_start;
+--------------+-------------------+-------------+---------------------------+---------------------+
| account_id   | linked_account_id | record_type | period_start              | blended_cost_amount |
+--------------+-------------------+-------------+---------------------------+---------------------+
| 12345678ORG1 | 98765432ACC1      | Usage       | 2022-05-01T05:30:00+05:30 | $4.31               |
| 12345678ORG1 | 98765432ACC2      | Usage       | 2022-05-01T05:30:00+05:30 | $803.52             |
| 12345678ORG1 | 98765432ACC3      | Usage       | 2022-05-01T05:30:00+05:30 | $496.84             |
| 12345678ORG1 | 98765432ACC4      | Usage       | 2022-05-01T05:30:00+05:30 | $8,736.72           |
| 12345678ORG1 | 98765432ACC5      | Usage       | 2022-05-01T05:30:00+05:30 | $140.24             |
| 12345678ORG2 | 98765432ACC6      | Usage       | 2022-05-01T05:30:00+05:30 | $3.38               |
| 12345678ORG2 | 98765432ACC7      | Usage       | 2022-05-01T05:30:00+05:30 | $0.00               |
| 12345678ORG2 | 98765432ACC8      | Usage       | 2022-05-01T05:30:00+05:30 | $0.48               |
| 12345678ORG2 | 98765432ACC9      | Usage       | 2022-05-01T05:30:00+05:30 | $6.75               |
+--------------+-------------------+-------------+---------------------------+---------------------+
select 
    account_id,
   period_start,
   period_end,
   mean_value::numeric::money  
from 
    all_aws.aws_cost_forecast_monthly
  where period_start>=date_trunc('month', now() - interval '1 months') AND
  period_end<=date_trunc('month', now() + interval '1 months') 
order by
  period_start;
+--------------+---------------------------+---------------------------+------------+
| account_id   | period_start              | period_end                | mean_value |
+--------------+---------------------------+---------------------------+------------+
| 123456789012 | 2022-05-01T05:30:00+05:30 | 2022-06-01T05:30:00+05:30 | $1,424.96  |
+--------------+---------------------------+---------------------------+------------+

vkumbha avatar May 12 '22 14:05 vkumbha

@vkumbha Thanks for raising this! We are aware of this requirement. While executing the master billing account query for aws_cost_by_record_type_monthly, it provides all the child accounts to date spent as expected. However, for aws_cost_forecast_monthly, we are checking if it extends the forecast data for each of the accounts or not. We will keep you posted.

rajlearner17 avatar May 13 '22 05:05 rajlearner17

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jul 12 '22 23:07 github-actions[bot]

'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.'

github-actions[bot] avatar Sep 07 '22 23:09 github-actions[bot]

'This issue was closed because it has been stalled for 60 days with no activity.'

github-actions[bot] avatar Oct 07 '22 23:10 github-actions[bot]