amazon-web-services - 以编程方式获取 AWS 成本和使用情况报告的内容
问题描述
我们每月都会安排进入S3 存储桶的报告。这些报告包括成本和使用信息(通过Cost Explorer配置)。
我不想从 S3 手动下载文件,而是希望能够随时以编程方式下载相同的内容(模式)。我在 S3 文件中有以下列(只是一个摘要,因为列表很长):
identity-oriented
bill-oriented
lineItem-oriented
product-oriented
pricing-oriented
reservation-oriented
savingsPlan-oriented
resourceTags-oriented
所以,与其等到月底才能获得这些内容,我希望能够每天查询它。可能某些列的值不会被精确计算(我知道一些调整通常发生在计费期间)。我找到的最接近的 CLI/API 如下:https ://awscli.amazonaws.com/v2/documentation/api/latest/reference/ce/get-cost-and-usage.html#get-cost-and-用法,但我觉得它不是那么强大(或者至少我不知道如何进行查询)以返回接近上述模式的模式。
我尝试过的是以下内容:
aws ce get-cost-and-usage --time-period Start=2021-05-25,End=2021-05-26 --granularity DAILY --metrics "UnblendedCost" "UsageQuantity" --group-by Type=DIMENSION,Key=SERVICE Type=TAG,Key=Project
它返回一些内容,但还远远不够。我还想包括SUBSCRIPTION_ID、定价货币、定价单位、使用量等。我希望有一个端点来返回预定报告中的内容。
如果我尝试以某种方式访问另一个维度(或另一个标签),我会继续得到:
An error occurred (ValidationException) when calling the GetCostAndUsage operation: Only two values for GroupBy are allowed
解决方案
推荐阅读
- vue.js - 带有 VueJS 的 Ag-Grid (vanillajs)
- google-apps-script - 使用 Google 工作表的 Google Script 轮班调度程序
- qt - 在 Jenkins Pipeline 中构建 Qt 项目
- objective-c - 在 OS X 上模拟 DS4 控制器以实现 PS4 远程播放
- java - Spring MVC 中 Redisson Hibernate 2L 缓存配置的问题
- django - 试图在 MAKEEMIGRATONS 期间运行的表单代码
- javascript - 在网页上显示 Content-Type: application/jpeg 结果
- sql - 如何仅在特定(更大)多边形中创建多边形对并计算该对中包含的所有点?
- powershell - 使用文件夹和子文件夹按需管理 OneDrive 文件
- amazon-web-services - 从 EC2 实例访问 AWS Secrets Manager 时出现权限错误