Access AWS billing information using python boto3 or any api ?

0

I am trying to get AWS Account Monthly billing information using python boto3 or any API using programmatic way. I couldn't find any resource related.

2回答
1
承認された回答

Use the get_cost_and_usage_with_resources API in which you need to add filters to get results on the services you would like to view costs monthly:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ce/client/get_cost_and_usage_with_resources.html

AWS
vtjean
回答済み 1年前
profile picture
エキスパート
レビュー済み 1ヶ月前
1
profile picture
エキスパート
回答済み 1年前
  • Actually cost and usage are more granular information but I just want information about total charge for a service in month.

  • You can also get monthly total charge easily lIke this.

    '''python res = boto3.client('ce').get_cost_and_usage( TimePeriod = {"Start": start_day, "End": end_day}, Granularity = "MONTHLY", Metrics = ["UnblendedCost"])

    print(f"TotalCost: {res['ResultsByTime'][0]['Total']['UnblendedCost']['Amount']}") '''

  • I see discrepancy in the amount showed using "cost explorer" vs "billing dashboard" for a month. for ex. in billing dashboard S3 and S3 glacier in total shows 1000 USD but in cost explorer for S3 service it is showing as 1040 USD. There is no difference even unblended, blended or amortized. why is this difference ?

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ