💰aws-billing-and-cost-management
- プラグイン
- aws-core
- ソース
- GitHub で見る ↗
説明
AWSのコストを分析し、節約機会の発見、予算管理、Savings PlansおよびReserved Instancesの評価、 Compute OptimizerによるEC2/Lambda/RDS/EBSの適正サイジング、サービス料金の照会、 AthenaによるCURのクエリ実行、コスト異常の検出、請求ビューへのコストのスコープ設定、 およびFree Tier使用状況のモニタリングを行います。 次のような場合に使用: AWSの請求書、コスト分析、支出削減、Savings Plan、Reserved Instance、 適正サイジング(right-size)、予算アラート、コスト最適化、料金確認、Free Tier、 コスト異常、CUR、コスト監査、請求ビュー、請求ビューARN。
原文を表示
Analyze AWS costs, find savings, manage budgets, evaluate Savings Plans and Reserved Instances, right-size EC2/Lambda/RDS/EBS with Compute Optimizer, look up service pricing, query CUR with Athena, detect cost anomalies, scope costs to billing views, and monitor Free Tier usage. Triggers on: AWS bill, cost analysis, reduce spend, savings plan, reserved instance, right-size, budget alert, cost optimization, pricing, free tier, cost anomaly, CUR, cost audit, billing view, billing view ARN.
ユースケース
- ✓AWSの請求額を確認したい
- ✓コスト削減の機会を探したい
- ✓EC2やLambdaのサイジングを最適化したい
- ✓コスト異常を検出したい
- ✓Free Tierの使用状況を監視したい
本文(日本語訳)
請求とコスト管理
概要
AWSのコストを分析・最適化・管理するためのスキルです。 AWSのコスト管理プロダクトに関するドメイン知識——よくある落とし穴、正しいAPI使用パターン、モデルが誤りやすい最適化ワークフロー——をエンコードしています。
使用方法
次のような場合に使用:
- AWSの支出、コストトレンド、コスト内訳を分析する
- 予算アラートを設定または管理する
- Savings PlansまたはReserved Instanceの購入を評価する
- EC2、Lambda、RDS、EBSリソースのサイズ適正化を行う
- AWSサービスの料金を調べる
- コスト監査を実施する、またはコストスパイクを調査する
- AthenaでCURデータをクエリする
- コスト分析を特定の請求ビューにスコープする
- 無料利用枠の使用状況を確認する
主要概念
- Cost Explorer — サービス・アカウント・タグ・期間でコスト/使用状況データをクエリ
- Budgets — アラート付きの支出しきい値を設定;請求ビューのスコープ指定に対応
- Billing Views — コストデータを請求の一部(カスタムビュー、請求グループ、またはプライマリ)にスコープ
- Compute Optimizer — EC2、Lambda、EBS、RDSのサイズ適正化推奨事項
- Cost Optimization Hub — サービス横断の節約推奨事項を集約
- Savings Plans / Reserved Instances — コミットメントベースの割引
- CUR 2.0 — Athenaでクエリ可能な詳細な明細課金データ
推奨セットアップ: サンドボックス実行・監査ログ・エンタープライズ制御には AWS MCPサーバーを使用してください。 参照: https://docs.aws.amazon.com/aws-mcp/
AWS MCPを使用しない場合: すべてのコマンドは標準のAWS CLI構文を使用し、CLIアクセス権を持つ任意のagentで動作します。
重要ルール: 現在の日付を必ず確認する
Cost Explorer・Budgets・Savings Plans のAPIコールを行う前に、必ず現在の日付を確認してください。 ツールを使用して現在の日時を取得し、年を推測や仮定で補わないでください。 LLMはトレーニングデータの日付をデフォルトとして使用しがちで、実際の現在日付ではない古いデータの分析結果を正しいように見せてしまうことがあります。
重要ルール: 決定論的な計算
レスポンス内の推論によって数値計算(合計・平均・パーセンテージ・比較・カウント・最小/最大)を行ってはなりません。 LLMの算術演算は信頼性が低く、コストデータで誤った結果を生成します。
APIコールから返されたデータに対する計算には、必ずスクリプトまたは電卓ツールを使用してください。
計算を実行して結果を出力するPythonスクリプトを記述してください。
AWS MCPサーバーの run_script ツールが利用可能な場合はそちらを使用し、それ以外はスクリプトをローカルで実行してください。
パターンと例については references/deterministic-calculations.md を参照してください。
判断ガイド
| 質問 | ツール | 参照先 |
|---|---|---|
| 何にいくら使っているか?どこでコストが増えているか? | Cost Explorer | references/cost-explorer.md |
| サービスのコストはいくらか? | Price List API | references/pricing-lookup.md |
| どこで節約できるか?(まずここから) | Cost Optimization Hub | references/cost-optimization-hub.md |
| Savings Plansを購入すべきか? | CE SP Recommendations | references/savings-plans.md |
| Reserved Instancesを購入すべきか? | CE RI Recommendations | references/reserved-instances.md |
| EC2/Lambda/EBS/RDSの特定の推奨事項を詳しく調べたい | Compute Optimizer | references/ec2-rightsizing.md, references/lambda-optimization.md, references/rds-optimization.md, references/ebs-optimization.md |
| 予算アラートはどう設定するか? | Budgets | references/budgets.md |
| コストスパイクの原因は? | Cost Anomaly Detection | references/cost-explorer.md |
| 無料利用枠の範囲内か? | Free Tier API | references/free-tier.md |
| 請求額を削減するには? | Cost Auditワークフロー | references/cost-audit.md |
| 詳細な課金データをクエリするには? | CUR 2.0 + Athena | references/cur-athena.md |
| 特定サービスを最適化するには? | サービスごとのパターン | references/service-optimization.md |
| コストを請求ビューにスコープするには? | Billing Views | 下記のBilling Viewsを参照 |
一般的なタスク
サービス別のコスト分析
aws ce get-cost-and-usage \
--time-period Start=2026-03-01,End=2026-04-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
デフォルトは UnblendedCost を使用してください。
クレジット/返金を除外するには --filter '{"Not":{"Dimensions":{"Key":"RECORD_TYPE","Values":["Credit","Refund"]}}}' を追加してください。
終了日は排他的(その日を含まない)です。
コスト監査の実施
7ステップのフルワークフロー(コスト上位ドライバー→前月比較→最適化推奨事項→アイドルリソース→コミットメントカバレッジ→サービス別クイックウィン→レポート)については references/cost-audit.md を参照してください。
サイズ適正化の推奨事項を取得する
Compute Optimizerはまずオプトインが必要です:
aws compute-optimizer update-enrollment-status --status Active
その後、EC2の場合は references/ec2-rightsizing.md、その他のリソースは該当するリファレンスを参照してください。
サービス料金を調べる
サービスコードと属性フィルターについては references/pricing-lookup.md を参照してください。
よくある落とし穴: Price List APIのサービスコードはCost Explorerのサービス名と異なります。
Billing Views
Billing Viewは、コストと使用状況データをアカウントの請求の特定のスライス(請求グループ、カスタムビュー、またはデフォルトのプライマリビューなど)にスコープします。
ユーザーが特定の請求ビューを通じてコストを分析したい場合、対応するAPIコールに --billing-view-arn を追加してください。
利用可能な請求ビューを確認する
aws billing list-billing-views \
--billing-view-types PRIMARY CUSTOM BILLING_GROUP
billing:ListBillingViews 権限が必要です。
Cost Explorerで請求ビューを使用する
aws ce get-cost-and-usage \
--time-period Start=2026-03-01,End=2026-04-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE \
--billing-view-arn arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID
請求ビューにスコープした予算を作成する
--budget のJSON内に BillingViewArn フィールドを含めてください:
aws budgets create-budget --account-id ACCOUNT_ID \
--budget '{
"BudgetName": "TeamX-Monthly",
"BudgetLimit": {"Amount": "1000", "Unit": "USD"},
"TimeUnit": "MONTHLY",
"BudgetType": "COST",
"BillingViewArn": "arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID"
}'
--billing-view-arn のAPIサポート状況
--billing-view-arn に対応 |
非対応 |
|---|---|
ce get-cost-and-usage |
ce get-reservation-coverage |
ce get-cost-and-usage-with-resources |
ce get-reservation-utilization |
ce get-cost-forecast |
ce get-savings-plans-coverage |
ce get-usage-forecast |
ce get-savings-plans-utilization |
ce get-dimension-values |
|
ce get-tags |
|
ce get-cost-comparison-drivers |
|
budgets create-budget(budget JSONの中) |
トラブルシューティング
| エラー | 原因 | 対処法 |
|---|---|---|
Cost Explorerの ValidationException |
ディメンションキーが誤っている(例: RECORD_TYPE の代わりに CHARGE_TYPE を使用) |
チャージタイプのフィルタリングには RECORD_TYPE を使用する |
| フィルター適用時に結果が空 | フィルター値が完全一致していない | まず GetDimensionValues を呼び出して有効な値を取得する |
時間別データで AccessDeniedException |
時間別粒度が有効化されていない | Cost Explorerの設定で有効化する |
Compute Optimizerで Account not registered |
オプトインしていない | update-enrollment-status --status Active を実行する |
| us-east-1以外でBudgets APIが失敗 | BudgetsはUS East (N. Virginia)が必要 | --region us-east-1 を指定する |
GroupBy使用時にCost Explorerの Total が空 |
仕様——グループ化時は合計が除外される | GroupByなしで別途コールを行うか、スクリプトでグループ化結果を集計する |
list-billing-views で AccessDeniedException |
権限が不足している | billing:ListBillingViews 権限を付与する |
--billing-view-arn で ValidationException |
APIが請求ビューに未対応、またはARNの形式が誤っている | 上記のAPIサポート表を確認;ARN形式は arn:aws:billing::ACCOUNT_ID:billingview/VIEW_ID |
予算のヘルスステータスが UNHEALTHY |
請求ビューのアクセスが取り消されたかビューが削除された | describe-budget 出力の HealthStatus.StatusReason を確認;billing:GetBillingViewData が付与されていることを確認する |
参考リソース
- AWS Cost Management ユーザーガイド: https://docs.aws.amazon.com/cost-management/
- AWS Pricing Calculator: https://calculator.aws/
- Compute Optimizer ユーザーガイド: https://docs.aws.amazon.com/compute-optimizer/
- Well-Architected コスト最適化の柱: https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/
原文(English)を表示
Billing and Cost Management
Overview
Analyze, optimize, and manage AWS costs. This skill encodes domain expertise from AWS's cost management products — gotchas, correct API usage patterns, and optimization workflows that models frequently get wrong.
Usage
Use this skill when:
- Analyzing AWS spending, cost trends, or cost breakdowns
- Setting up or managing budget alerts
- Evaluating Savings Plans or Reserved Instance purchases
- Right-sizing EC2, Lambda, RDS, or EBS resources
- Looking up AWS service pricing
- Running cost audits or investigating cost spikes
- Querying CUR data with Athena
- Scoping cost analysis to a specific billing view
- Checking Free Tier usage
Core Concepts
- Cost Explorer — query cost/usage data by service, account, tag, or time range
- Budgets — set spending thresholds with alerts; supports billing view scoping
- Billing Views — scope cost data to a subset of billing (custom view, billing group, or primary)
- Compute Optimizer — right-sizing recommendations for EC2, Lambda, EBS, RDS
- Cost Optimization Hub — aggregated savings recommendations across services
- Savings Plans / Reserved Instances — commitment-based discounts
- CUR 2.0 — detailed line-item billing data queryable via Athena
Recommended setup: Use the AWS MCP server for sandboxed execution, audit logging, and enterprise controls. See: https://docs.aws.amazon.com/aws-mcp/
Without AWS MCP: All commands use standard AWS CLI syntax and work with any agent that has CLI access.
Critical Rule: Always Check the Current Date
Before making ANY Cost Explorer, Budgets, or Savings Plans API call, you MUST determine the current date. Use a tool to get the current date and time — do NOT assume or guess the year. LLMs frequently default to dates from their training data instead of the actual current date, producing analyses of stale data that appear correct but are completely wrong.
Critical Rule: Deterministic Calculations
You MUST NEVER perform numerical calculations (sums, averages, percentages, comparisons, counts, min/max) by reasoning in your response. LLM arithmetic is unreliable and produces wrong answers on cost data.
You MUST ALWAYS use a script or calculator tool for any math on data returned from API calls. Write a Python script that performs the calculation and prints the result. If the AWS MCP server's run_script tool is available, use it. Otherwise, run the script locally.
Read references/deterministic-calculations.md for patterns and examples.
Decision Guide
| Question | Tool | Reference |
|---|---|---|
| What am I spending? Where are costs going up? | Cost Explorer | references/cost-explorer.md |
| How much does a service cost? | Price List API | references/pricing-lookup.md |
| Where can I save money? (start here) | Cost Optimization Hub | references/cost-optimization-hub.md |
| Should I buy Savings Plans? | CE SP Recommendations | references/savings-plans.md |
| Should I buy Reserved Instances? | CE RI Recommendations | references/reserved-instances.md |
| Deep-dive on a specific EC2/Lambda/EBS/RDS rec? | Compute Optimizer | references/ec2-rightsizing.md, references/lambda-optimization.md, references/rds-optimization.md, references/ebs-optimization.md |
| How do I set up budget alerts? | Budgets | references/budgets.md |
| What's causing a cost spike? | Cost Anomaly Detection | references/cost-explorer.md |
| Am I within Free Tier? | Free Tier API | references/free-tier.md |
| How do I reduce my bill? | Cost Audit workflow | references/cost-audit.md |
| How do I query detailed billing data? | CUR 2.0 + Athena | references/cur-athena.md |
| How do I optimize specific services? | Per-service patterns | references/service-optimization.md |
| How do I scope costs to a billing view? | Billing Views | See Billing Views below |
Common Tasks
Analyze costs by service
aws ce get-cost-and-usage \
--time-period Start=2026-03-01,End=2026-04-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
Default to UnblendedCost. Exclude Credits/Refunds with --filter '{"Not":{"Dimensions":{"Key":"RECORD_TYPE","Values":["Credit","Refund"]}}}'. End date is exclusive.
Run a cost audit
Read references/cost-audit.md for the full 7-step workflow: top cost drivers → month-over-month comparison → optimization recommendations → idle resources → commitment coverage → per-service quick wins → report.
Get right-sizing recommendations
Compute Optimizer requires opt-in first: aws compute-optimizer update-enrollment-status --status Active. Then read references/ec2-rightsizing.md for EC2 or the relevant resource-specific reference.
Look up service pricing
Read references/pricing-lookup.md for service codes and attribute filters. Common trap: Price List API service codes differ from Cost Explorer service names.
Billing Views
A billing view scopes cost and usage data to a specific slice of an account's billing (e.g., a billing group, custom view, or the default primary view). When the user wants to analyze costs through a particular billing view, add --billing-view-arn to supported API calls.
Discover available billing views
aws billing list-billing-views \
--billing-view-types PRIMARY CUSTOM BILLING_GROUP
Requires billing:ListBillingViews permission.
Use a billing view with Cost Explorer
aws ce get-cost-and-usage \
--time-period Start=2026-03-01,End=2026-04-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE \
--billing-view-arn arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID
Create a budget scoped to a billing view
In the --budget JSON, include the BillingViewArn field:
aws budgets create-budget --account-id ACCOUNT_ID \
--budget '{
"BudgetName": "TeamX-Monthly",
"BudgetLimit": {"Amount": "1000", "Unit": "USD"},
"TimeUnit": "MONTHLY",
"BudgetType": "COST",
"BillingViewArn": "arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID"
}'
API support for --billing-view-arn
Supports --billing-view-arn |
Does NOT support it |
|---|---|
ce get-cost-and-usage |
ce get-reservation-coverage |
ce get-cost-and-usage-with-resources |
ce get-reservation-utilization |
ce get-cost-forecast |
ce get-savings-plans-coverage |
ce get-usage-forecast |
ce get-savings-plans-utilization |
ce get-dimension-values |
|
ce get-tags |
|
ce get-cost-comparison-drivers |
|
budgets create-budget (in budget JSON) |
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
ValidationException on Cost Explorer |
Wrong dimension key (e.g., CHARGE_TYPE instead of RECORD_TYPE) |
Use RECORD_TYPE for charge type filtering |
| Empty results with filter | Filter value doesn't match exactly | Call GetDimensionValues first to get valid values |
AccessDeniedException on hourly data |
Hourly granularity not enabled | Enable in Cost Explorer preferences |
Account not registered on Compute Optimizer |
Not opted in | Run update-enrollment-status --status Active |
| Budgets API fails outside us-east-1 | Budgets requires us-east-1 | Set --region us-east-1 |
Cost Explorer Total empty with GroupBy |
By design — totals excluded when grouping | Make separate call without GroupBy, or sum grouped results using a script |
AccessDeniedException on list-billing-views |
Missing permission | User needs billing:ListBillingViews permissions |
ValidationException with --billing-view-arn |
API doesn't support billing views, or malformed ARN | Check the API support table above; ARN format is arn:aws:billing::ACCOUNT_ID:billingview/VIEW_ID |
Budget shows UNHEALTHY health status |
Billing view access revoked or view deleted | Check HealthStatus.StatusReason in describe-budget output; ensure billing:GetBillingViewData is granted |
Additional Resources
- AWS Cost Management User Guide: https://docs.aws.amazon.com/cost-management/
- AWS Pricing Calculator: https://calculator.aws/
- Compute Optimizer User Guide: https://docs.aws.amazon.com/compute-optimizer/
- Well-Architected Cost Optimization Pillar: https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。