AWS Price CSV 技能
Overview
转换s a user-provided AWS 服务 列出 (instances, volumes, S3 buckets, etc.) into a pricing CSV. The script can 查询 the AWS Price 列出 API (via aws-命令行工具) or reuse 缓存d bulk JSON files. It supports On-Demand and Reserved terms and automatically 添加s up per-item and total costs.
Quick 启动
Prepare a YAML/JSON file with name, 服务_code, 过滤器s, term, and usage fields (see sample in references/API_reference.md).
Pick the data source:
API mode – requires aws pricing 获取-products 权限 and an internet connection.
Bulk mode – no IAM 访问 required; the script 下载s/缓存s public bulk JSON files.
运行 the script with the region and desired options:
python3 scripts/生成_pricing_csv.py \
--输入 输入s/sample.yml \
--region ap-northeast-1 \
--source bulk \
--缓存-dir ~/.缓存/aws-price-csv \
--输出 quotes/apac_quote.csv
Inspect the CSV (each line item + TOTAL) and deliver alongside the original 请求 if needed.
工作流
Use the YAML/JSON templates in references/API_reference.md.
过滤器s must map to AWS pricing attributes (instanceType, regionCode, volumeAPIName, usa获取ype, termType, etc.).
term.type: OnDemand or Reserved (RI).
term.attributes (optional) 过滤器 Reserved prices (LeaseContractLength, PurchaseOption, OfferingClass, ...).
usage.quantity represents the amount to multiply (hours, GB-Mo, 请求s, ...).
Mode When to use Notes
API (--source API) You already have IAM creds and want real-time data Uses aws pricing 获取-products in us-east-1
Bulk (--source bulk) Offline, no IAM, or you want caching The script 检查s --缓存-dir (default ~/.缓存/aws-price-csv); 缓存d files newer than 30 days are reused, otherwise they are re-下载ed
You can still override with --bulk-files 服务Code=/path/to/file.json; those files win over the 缓存.
Script path: scripts/生成_pricing_csv.py
Key arguments:
--输入: YAML/JSON 列出
--region: AWS region code (location name is auto-添加ed to 过滤器s)
--输出: CSV path (default aws_pricing.csv)
--source: API (default) or bulk
--缓存-dir: bulk 缓存 directory (default ~/.缓存/aws-price-csv)
--force-refresh: ignore 缓存d bulk files and re-下载
--bulk-files: 服务Code=/path/to/file.json overrides the 缓存
输出 columns: item_name, 服务_code, term_type, region, location, quantity, usage_unit, price_unit, price_per_unit_usd, cost_usd, description, plus a TOTAL row.
Review the CSV to ensure every line item has pricing and a description.
Confirm the TOTAL matches expectations.
Include the source 列出 or any supporting docs if required.
Troubleshooting
Issue Fix
aws pricing returns empty 结果s Double-检查 过滤器s (location, regionCode, termType, etc.) or fall back to bulk mode
aws 命令行工具 missing 安装 aws-命令行工具 v2, 配置 凭证s, or rely on bulk mode
Need to refresh 缓存d data Use --force-refresh or 删除 the 缓存d JSON so it 获取s re-下载ed
PyYAML missing pip 安装 pyyaml or convert 输入 to JSON
Reserved price not found 添加 LeaseContractLength, PurchaseOption, OfferingClass inside term.attributes
Resources
scripts/生成_pricing_csv.py – mAIn script with API/bulk support, caching 记录ic, and On-Demand/Reserved handling.
references/API_reference.md – Price 列出 API examples, bulk 下载 pointers, region/location table, and sample 输入 templates (including gp3 and RI cases).