Skip to content

yorosiku008/finops-cli

Repository files navigation

FinOps JP CLI

AWS Cost Explorer のデータを取得し、Claude AI が日本語でコスト削減提案を生成するCLIツール。

Tests Beta

デモ

$ python main.py --demo

*** FinOps JP -- Cost Analysis (2026-03-29 ~ 2026-04-28)
============================================================
Total: $4,832.10

  Service    Cost ($)   Pct (%)   Graph
 ──────────────────────────────────────
  EC2       $2,104.50     43.6%   ########
  RDS       $1,203.20     24.9%   ####
  S3          $389.00      8.1%   #
  Lambda      $210.80      4.4%
  その他      $924.60     19.1%   ###

AI Suggestions (Claude)
  1. m5.xlarge 3台を Reserved Instance (1年) に切替 → 月$420削減
  2. 未使用EBSボリューム12個 (合計480GB) を削除 → 月$89削減
  3. S3 Intelligent-Tiering を全バケットに適用 → 月$67削減

セットアップ

1. 依存ライブラリのインストール

pip install -r requirements.txt

2. AWS IAMポリシー設定

iam_policy.json を IAM ポリシーに適用します(ReadOnly 権限のみ)。

3. 環境変数設定

# Windows
set ANTHROPIC_API_KEY=sk-ant-...

# Mac/Linux
export ANTHROPIC_API_KEY=sk-ant-...

使い方

# デモモード(AWS・Claude API 不要)
python main.py --demo

# 本番モード
python main.py --profile mycompany --days 30

# コスト上位5件のみ表示
python main.py --profile mycompany --days 30 --top 5

# 100USD 未満のサービスを除外
python main.py --profile mycompany --days 30 --min-cost 100

# MDレポートも出力(C:\claude_c\report_YYYYMMDD.md)
python main.py --profile mycompany --days 30 --output-md

# Windows バッチ(UTF-8設定込み)
run.bat --profile mycompany --days 30

オプション

オプション デフォルト 説明
--profile default AWS プロファイル名
--days 30 集計日数
--top 全件 コスト上位N件のみ表示(例: --top 5
--min-cost なし 表示する最小コスト(USD)。未満を除外
--output-md false MDレポートを出力
--demo false デモデータで動作確認

テスト

python -m pytest tests/ -v   # Mac/Linux
test.bat                      # Windows

26 テスト全パス。AWS・Claude API への通信はすべてモックしているため、外部接続なしで実行可能。

ライセンス

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors