範例:快速審計一個帳戶
目標: 幾分鐘內得到一個帳戶易於閱讀的 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。