aws-samples / aws-cost-explorer-report

Python SAM Lambda module for generating an Excel cost report with graphs, including month on month cost changes. Uses the AWS Cost Explorer API for data.
MIT No Attribution
432 stars 166 forks source link

Doesn't work when run from linked accounts #22

Open sidbose87 opened 5 years ago

sidbose87 commented 5 years ago

First of all, thanks for the code. I am looking for a cost & usage report for my linked account, I know aws doesn't support such reports for linked accounts, that is why I am looking for some kind of in house python code. I thought of working out the getAccounts module to change it use only my account ID. But doesn't seem to work.

nikolaigauss commented 3 years ago

I've just done this:

        self.accounts = {} #We don't have permission to list accounts in org so this is irrelevant
        # try:
        #     self.accounts = self.getAccounts()
        # except:
        #     logging.exception("Getting Account names failed")
        #     self.accounts = {}

    # def getAccounts(self):
    #     accounts = {}
    #     client = boto3.client('organizations', region_name='us-east-1')
    #     paginator = client.get_paginator('list_accounts')
    #     response_iterator = paginator.paginate()
    #     for response in response_iterator:
    #         for acc in response['Accounts']:
    #             accounts[acc['Id']] = acc
    #     return accounts

But I had to deploy the report per each linked account, hope this helps :).