示例:快速审计一个账户
目标: 几分钟内得到一个账户易于阅读的 Excel 和 Word 清单。
你需要: 该账户的凭证,例如
aws sso login --profile prod-readonly 和 export AWS_PROFILE=prod-readonly。
未针对 AWS CLI 验证:本节中的登录命令。
模板
内置的 single-account 配置模板会扫描 us-east-1,并使用 standard-bom 版式写出两个文件。
复制它并设置你的区域:
Terminal
inventag templates init single-account --output .inventag/templates/audit.yaml
.inventag/templates/audit.yaml
format_version: 1
kind: config
name: audit
description: Scan the account of your current credentials and write Excel and Word reports.
spec:
regions: [us-east-1, eu-west-1] # the regions you use
outputs: [excel, word]
output_directory: bom_output
report_template: standard-bom
命令
Terminal
inventag templates validate audit
inventag --template audit
输出
以下是同一版式、使用一个区域参数的离线运行结果(示例数据;IAM 列在区域 global 下,所以摘要统计为 2 个区域):
输出
inventag - WARNING - - No account specification method provided. Using default AWS credentials.
Wrote bom_output/multi_account_bom_20261112_090000.docx
Wrote bom_output/multi_account_bom_20261112_090000.xlsx
工作表: Summary、ATHENA、DYNAMODB、EC2、EVENTS、IAM、KMS、LAMBDA、S3、VPC
Summary 工作表:
AWS Resource Inventory
Bill of materials generated by InvenTag
Generated: 2026-11-12 09:00 UTC
Accounts: 1 Regions: 2
| Service | Resources | Share |
|---|---|---|
| ATHENA | 1 | 2.7% |
| DYNAMODB | 1 | 2.7% |
| EC2 | 4 | 10.8% |
| EVENTS | 1 | 2.7% |
| IAM | 1 | 2.7% |
| KMS | 14 | 37.8% |
| LAMBDA | 1 | 2.7% |
| S3 | 4 | 10.8% |
| VPC | 10 | 27.0% |
| Total | 37 | 100.0% |
工作表: Summary、ATHENA、DYNAMODB、EC2、EVENTS、IAM、KMS、LAMBDA、S3、VPC
S3 工作表的前几行:
| Account | Region | Service | Type | Name | ID | ARN | Tag: CostCenter | Tag: DataClassification | Tag: Environment | Tag: Owner | ... |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 123456789012 | us-east-1 | S3 | Bucket | acme-app-logs | acme-app-logs | arn:aws:s3:::acme-app-logs | CC-1001 | internal | prod | platform | ... |
| 123456789012 | us-east-1 | S3 | Bucket | acme-data-lake | acme-data-lake | arn:aws:s3:::acme-data-lake | CC-2002 | prod | data | ... | |
| 123456789012 | us-east-1 | S3 | Bucket | acme-reports | acme-reports | arn:aws:s3:::acme-reports | 1234 | Production | finance | ... | |
| 123456789012 | us-east-1 | S3 | Bucket | acme-scratch | acme-scratch | arn:aws:s3:::acme-scratch | ... |
该工作表共有 12 列;此处显示前 11 列。
下一步
- 添加标签检查:
inventag --template audit --template security-baseline。 - 常含机密的字段的值(例如 Lambda 环境变量)在报告中显示为
***REDACTED***。 - 每周运行一次:在 CI/CD 中运行 InvenTag。