跳到主要内容
版本:v1.4.1(当前)

输出文件

适合谁阅读: 你要在脚本中处理 InvenTag 的输出,或向他人解释这些报告。

读完后你会知道: InvenTag 写出的每个文件的名称、位置和内容。

所有文件都写入输出文件夹:默认是 bom_output/,除非你设置了 --output-directory,或在配置模板中设置了 output_directory。 InvenTag 写入的其他位置只有你指定的文件(--log-file、--audit-output、templates init --output)、使用 --s3-bucket 时的 S3 存储桶,以及使用 Google 选项时的 Google Drive;使用 --google-oauth-client 时还有位于 ~/.config/inventag/google-token.json 的登录令牌文件。

输出文件创建后只有你的用户可以读写,新建的输出文件夹同样只对你的用户私有。

未针对 Windows 验证:文件和文件夹仅对你的用户私有。

本页的示例来自针对模拟 AWS 的离线运行(示例数据)。

文件列表​

文件何时生成内容
multi_account_bom_<timestamp>.xlsx--create-excel,或没有指定任何输出参数Excel 报告
multi_account_bom_<timestamp>.docx--create-wordWord 报告
<account-id>_bom_<timestamp>.xlsx 和 .docx--per-account-reports,代替 multi_account_bom_* 文件每个有资源的账户一份报告
tag_compliance_<timestamp>.json启用了标签策略标签检查结果
state/state_<timestamp>.json每次运行,除非使用 --disable-state-management所发现的每个资源的快照,机密值已被遮盖。metadata.tags.coverage_summary 按账户统计列出调用的结束方式(ok、empty、denied、throttled、error、timeout,以及 --account-services 排除的服务对应的 out_of_scope)。metadata.tags.units_not_read 列出未能读取的列出调用(仅在有调用失败时出现),metadata.tags.inventag_version 记录写出该快照的 InvenTag 版本。超过 30 天的快照,或最新 100 份之外的快照会被删除(--state-retention-days、--state-max-snapshots)。
state/metadata.json有快照时快照索引:时间、账户、区域、资源数量、校验和
changelog_<timestamp>.md第二次及之后的运行,除非使用 --no-generate-changelog 或 --disable-delta-detection自上一份快照以来新增、删除或变更了什么。见跟踪变更。
你用 --audit-output 指定的文件你要求时本次运行调用的每个 AWS 操作
state/partial/<key>/<account-id>.json有账户失败的运行已完成账户的结果,供 --resume 复用,完整运行后会被删除

<timestamp> 的格式是 YYYYMMDD_HHMMSS。报告、Word、变更日志和标签合规文件的名称使用你电脑的本地时间。快照和 S3 文件夹使用 UTC。

默认工作簿为每个 API 字段提供一个 raw_data.* 列,因此工作表可能很宽。快照是带缩进的 JSON,包含每个资源的完整 raw_data,因此可能很大。目前没有选项可以省略 raw_data.* 列或压缩快照;两者都计划在以后的版本中提供。

Excel 报告​

不使用模板时,工作簿包含:

  • Summary: Service、Resource Count、Percentage,以及合计。
  • 每个服务一个工作表(例如 EC2、S3、VPC),按服务名称排序,包含其资源上发现的所有字段, 包括展平后的 raw_data.* 和 tags.* 列。以 ID 为键的映射类型 API 字段放在一个 JSON 单元格中。行按类型、名称和 ID 排序。 每行都有 source 列(service-api、tagging-api 或 billing:返回该行的 API)、 sources 列(所有这些 API,用 + 连接)和 detail_level 列(来自服务自身 API 的行为 full,其他为 identity)。
  • Network Analysis 和 Security Analysis 工作表,仅在使用 --enable-network-analysis 或 --enable-security-analysis 时出现。
  • Cost Analysis 工作表,仅在使用 --enable-cost-analysis 时出现:根据 AWS Pricing API 估算的每月费用,不是你的账单。
  • FinOps 工作表,位于最后,仅在使用 --finops-checks 时出现:见 FinOps 工作表和 finops_checks 键。

常用于存放机密的字段(例如 Lambda 环境变量、CloudFormation 堆栈输出、Glue 触发器参数、连接字符串和签名 URL)的值,在每份报告、快照和日志中都显示为 ***REDACTED***。 字段名称会保留。参见功能状态。

使用报告模板时,版式遵循模板:

  • Summary: 标题、生成时间、账户和区域数量、一张 Service / Resources / Share 表, 以及(有标签策略时)合规计数。
  • 资源工作表: 每个服务一个,或使用 layout: single-sheet 时只有一个工作表。表头行默认带样式、已冻结并可筛选。
  • Tag Compliance(有标签策略时):范围内每个资源一行,之后是一张规则表,列出缺失和无效的计数。

工作表名称遵循 Excel 的规则:最多 31 个字符,且不含 [ ] : * ? / \。 重名的工作表会加上编号。以 = 开头的单元格值会按文本存储,绝不会作为公式。 行按服务、类型、名称和 ID 排序。

每种版式的预览由真实文件制作,见内置模板。

FinOps 工作表和 finops_checks 键​

使用 --finops-checks 时,默认工作簿以一个 FinOps 工作表结束。第一行是一条说明,然后是列出的结果,列为 Check ID、Check、Result、Reason、Account、Region、Service、Resource Type、Resource ID、Name 和 Observed,按检查 ID、账户、区域和资源 ID 排序。随后是一张表,列出每项检查的计数(Fail、Not evaluated、Pass)。使用 --template 时不写 FinOps 工作表。

命令行不为这些结果写 JSON 文件。在 Python 中,CloudBOMGenerator.generate_multi_account_bom() 的结果带有 finops_checks 键,用 json 输出格式写出的 JSON 报告的 metadata 中也有这个键。不使用该参数时没有这个键。字段见 FinOps 检查。

Word 报告​

不使用模板时: 一个标题、一份执行摘要、一张服务表,以及每个服务最多 50 个资源,共六列:Name、Id、Type、Region、Tags 和 Service。如果该服务的资源都没有名称,则这六列是 Id、Type、Region、Tags、Service 和 Source Account Name。

使用报告模板时: 即 word.sections 中列出的各节。表格的表头行会在每页重复,并为屏幕阅读器标记为表头。 徽标(如果有)带有替代文本。

标签合规 JSON​

tag_compliance_20261112_090000.json (one resource shown)
{
"policy": "finops-cost-allocation",
"description": "Requires CostCenter, Owner, Project and Environment so spend can be allocated.",
"summary": {
"checked": 23,
"compliant": 1,
"non_compliant": 22,
"out_of_scope": 14,
"percent_compliant": 4.3,
"missing_by_key": {
"CostCenter": 20,
"Owner": 17,
"Project": 21,
"Environment": 17
},
"invalid_by_key": {
"CostCenter": 1,
"Owner": 0,
"Project": 0,
"Environment": 1
}
},
"non_compliant_resources": [
{
"account": "123456789012",
"service": "S3",
"resource_type": "Bucket",
"resource_id": "acme-reports",
"arn": "arn:aws:s3:::acme-reports",
"region": "us-east-1",
"missing": [],
"invalid": [
"CostCenter: '1234' does not match CC-[0-9]{4}",
"Environment: 'Production' is not one of prod, staging, dev, test, sandbox"
]
}
]
}

快照​

bom_output/ after two runs (reports omitted)
bom_output/changelog_20261112_090100.md
bom_output/state/metadata.json
bom_output/state/state_20261112_090000.json
bom_output/state/state_20261112_090100.json
state/state_<timestamp>.json (structure)
{
"top_level_keys": [
"compliance_data",
"metadata",
"network_analysis",
"resources",
"security_analysis"
],
"one_resource": {
"service": "S3",
"resource_type": "Bucket",
"resource_id": "acme-app-logs",
"arn": "arn:aws:s3:::acme-app-logs",
"region": "us-east-1",
"tags": {
"Environment": "prod",
"Owner": "platform",
"CostCenter": "CC-1001",
"Project": "storefront",
"DataClassification": "internal"
},
"source_account_id": "123456789012"
}
}

审计 JSON​

audit.json (first operations shown)
{
"read_only_enforced": true,
"started_at": "2026-11-12T09:00:00+00:00",
"generated_at": "2026-11-12T09:00:00+00:00",
"allowed_prefixes": [
"List",
"Describe",
"Get",
"Head",
"Lookup",
"Search",
"BatchGet"
],
"total_calls": 93,
"allowed_calls": 93,
"blocked_calls": 0,
"operations": [
{
"service": "acm",
"operation": "ListCertificates",
"allowed": true,
"count": 1
},
{
"service": "apigateway",
"operation": "GetRestApis",
"allowed": true,
"count": 1
},
{
"service": "appsync",
"operation": "ListGraphqlApis",
"allowed": true,
"count": 1
},
{
"service": "athena",
"operation": "ListWorkGroups",
"allowed": true,
"count": 1
},
{
"service": "autoscaling",
"operation": "DescribeAutoScalingGroups",
"allowed": true,
"count": 1
},
{
"service": "backup",
"operation": "ListBackupVaults",
"allowed": true,
"count": 1
},
"..."
],
"blocked": []
}

S3 对象​

使用 --s3-bucket acme-inventory-reports --s3-key-prefix bom-reports/ 时,每次运行都会把文件放在以该次运行命名的文件夹下:

Objects in s3://acme-inventory-reports
bom-reports/20261112_090000/multi_account_bom_20261112_090000.xlsx

终端输出​

不使用 --verbose 时,运行会打印警告、错误和已写出的文件。 使用模板时,每个文件会打印为 Wrote <path>,如果启用了标签策略,随后还有一行标签策略摘要。不使用模板时,默认报告会打印为 Data exported to <path>。

退出码​

见命令行参考。