CrypticDriver/aws-resource-catalog

GitHub: CrypticDriver/aws-resource-catalog

该项目提供了一个机器可读的 AWS 可计费资源目录,整合了资源生命周期与孤儿资源检测规则,帮助下游工具回答账单含义并识别潜在浪费。

Stars: 0 | Forks: 0

# aws-resource-catalog 一个机器可读的目录,包含可计费的 AWS 资源类型、其生命周期以及孤儿资源检测规则。 此仓库回答了 AWS 未在同一处记录的两个问题: 1. **这个账单明细项究竟是什么?**(例如 `USE1-EMRWAL-WALHours` → Amazon EMR WAL 工作区存储) 2. **此资源何时会成为在其父资源消失后仍继续扣费的孤儿资源?** 它是下游工具(闲置检测器、MCP 服务器、FinOps 报告、AI 智能体)的知识源。 ## 布局 ``` aws-resource-catalog/ ├── schemas/ # JSON Schemas (resource.v1.json) ├── catalog/ # auto-pulled (refresh_catalog.py) │ ├── pricing_offers_index.json │ ├── boto3_services.json │ └── cfn_resource_types.json ├── knowledge/ # human-curated resource definitions (yaml) │ ├── ec2/ │ ├── emr/ │ ├── vpc/ │ └── ... ├── aws_resource_catalog/ # Python loader package │ └── __init__.py ├── scripts/ │ └── refresh_catalog.py └── tests/ └── test_yaml_valid.py ``` ## 快速开始 ``` pip install pyyaml jsonschema python -c " from aws_resource_catalog import Catalog cat = Catalog.load('knowledge/') for r in cat.filter(orphan_prone=True, severity='high'): print(r.id, '-', r.resource_type['human_name']) print(cat.stats()) " ``` ## Schema (v1) 每个资源都是位于 `knowledge//.yaml` 下的单个 yaml 文件。有关完整的 schema,请参阅 `schemas/resource.v1.json`。必填字段: - `service` — 简短的服务名称 - `resource_type.name` / `resource_type.human_name` - `billing.billable` / `billing.model` / `billing.summary` - `lifecycle.parent_resource` / `lifecycle.auto_delete_on_parent_delete` 可选但推荐: - `orphan_detection.*` — 判断规则 + 清理命令 + IAM - `verification.last_verified` + `contributor` - `tags` — 自由格式标签 ## 添加新资源类型 ``` # 1. 找到正确的服务文件夹 mkdir -p knowledge/ # 2. 复制现有的 yaml 作为起点 cp knowledge/vpc/elastic_ip.yaml knowledge//.yaml # 3. 填写字段(始终引用官方 AWS 文档锚点) # 4. 验证 pip install pytest pytest tests/test_yaml_valid.py ``` ## 刷新自动拉取的目录 ``` python scripts/refresh_catalog.py git add catalog/ git commit -m "refresh catalog YYYY-MM-DD" ``` ## 使用者 此仓库旨在作为 git submodule 或通过 pip install 使用: ``` # 作为 submodule(固定 commit) git submodule add https://github.com/CrypticDriver/aws-resource-catalog shared/catalog # 或者作为 pip 包(发布后) pip install aws-resource-catalog ``` 然后在代码中: ``` from aws_resource_catalog import Catalog cat = Catalog.load_default() # finds knowledge/ next to package ``` ## 许可证 MIT。
标签:AWS, DPI, FinOps, Python, 安全规则引擎, 成本优化, 无后门, 资源目录, 逆向工具