aws-billing-and-cost-management
aws/agent-toolkit-for-aws
AWSのコストを分析し、削減の余地を見つけ、予算を管理し、セービングプランや リザーブドインスタンスを評価し、Compute Optimizerを使用してEC2/Lambda/RDS/EBSを適正規模に調整し、 サービスの価格を検索し、AthenaでCURを照会し、コストの異常を検出し、 コストを請求ビューに絞り込み、無料利用枠の使用状況を監視します。 トリガー対象: AWS請求書、コスト分析、支出削減、Savings Plan、リザーブドインスタンス、 適正規模化、予算アラート、コスト最適化、価格、フリーティア、コスト 異常、CUR、コスト監査、請求ビュー、請求ビューARN。
...すべて拡張します概要aws-billing-and-cost-management
AWSのコストを分析、最適化、管理し、一般的な落とし穴、正しいAPIの使用パターン、最適化ワークフローなど、AWSのコスト管理製品に関する専門知識を反映しています。支出やコストの傾向の分析、予算アラートの設定、Savings PlanやReserved Instanceの評価、EC2の適正サイズ設定、 Lambda、RDS、EBSリソースの適正化、サービス料金の照会、コスト監査の実施やコスト急増の調査、AthenaによるCURデータのクエリ実行、請求ビューを範囲とした分析、およびFree Tierの利用状況の確認などに使用されます。 主要な概念には、Cost Explorer、Budgets、Billing Views、Compute Optimizer、Cost Optimization Hub、Savings PlansおよびReserved Instances、そしてAthenaを介してクエリを実行するCUR 2.0が含まれます。 AWS MCPサーバーは、サンドボックス環境での実行や監査ログの記録に推奨される設定ですが、コマンドは標準のAWS CLIアクセス権を持つ任意のエージェントでも動作します。
2つの重要なルールが強調されています。Cost Explorer、Budgets、またはSavings Plansの呼び出しを行う前に、ツールを使用して現在の日付を特定する必要があります。これは、モデルがデフォルトでトレーニングデータの年を基準とし、古いデータを分析してしまうことが多いためです。 合計、平均、割合、比較、個数などの数値計算は、決してレスポンスから推論してはならず、常にスクリプトや計算ツールを使用して行う必要があります。これは、コストデータに対するLLMによる算術処理は信頼性が低いためです。
意思決定ガイドでは、各質問を適切なツールや参照ファイルに誘導し、一般的なタスクのセクションでは具体的なコマンドを示しています。 サービスごとのコストは、`aws ce get-cost-and-usage` を使用して分析します。この際、SERVICE でグループ化し、デフォルトで `UnblendedCost` を指定し、RECORD_TYPE フィルターでクレジットと払い戻しを除外し、終了日は含めないものとします。 Compute Optimizer を利用するには、`update-enrollment-status` コマンドを使用してステータスを `Active` に設定し、オプトインする必要があります。「Billing Views」セクションでは、 --billing-view-arn を指定する方法について解説し、aws billing list-billing-views による請求ビューの一覧表示や、予算 JSON への BillingViewArn の含め方、および Cost Explorer の各 API が billing-view ARN をサポートしているか否かを示した表を掲載しています。 トラブルシューティング表では、誤ったディメンションキーによる `ValidationException`、フィルタリング結果が空の場合、時間単位のデータに対する `AccessDenied`、および予算が us-east-1 での実行を必要とするといったエラーと、それぞれの解決策を対応付けています。
よくある質問
コスト API を呼び出す前に、なぜ現在の日付を確認する必要があるのですか?
LLM は、実際の現在の日付ではなく、トレーニングデータの日付をデフォルトとして使用することが多く、一見正しいように見えて実際には間違っている、古いデータに基づく分析結果を生成してしまいます。Cost Explorer、Budgets、または Savings Plans の呼び出しを行う前には、ツールを使用して現在の日付を確認する必要があります。
コストデータの数値計算はどのように行うべきですか?
決してレスポンスの内容に基づいて推論してはいけません。合計、平均、パーセンテージ、比較、個数、最小値や最大値の計算は、常にスクリプトや計算ツール(結果を表示するPythonスクリプトなど)を使用して行う必要があります。これは、LLMによるコストデータの算術演算は信頼できないためです。
コスト分析の対象を特定の請求ビューに限定するにはどうすればよいですか?
サポートされている API 呼び出しに `--billing-view-arn` を追加し、`aws billing list-billing-views` で利用可能なビューを確認してください(`billing:ListBillingViews` 権限が必要です)。 サポートされている呼び出しには `ce get-cost-and-usage` および `get-cost-forecast` が含まれますが、リザーベーションおよびセービングプランのカバレッジや利用状況に関する呼び出しではサポートされていません。
Compute Optimizer にはどのような設定が必要ですか?
まず、`aws compute-optimizer update-enrollment-status` を実行し、ステータスを `Active` に設定してオプトインする必要があります。登録されていない場合、呼び出しは「Account not registered」エラーで失敗します。
us-east-1 以外のリージョンで Budgets API 呼び出しが失敗するのはなぜですか?
Budgets API では us-east-1 リージョンが必須です。トラブルシューティングの指針として、Budgets API 呼び出しの際はリージョンを us-east-1 に設定してください。
すべてのファイル
16ファイルreferences/cost-explorer.md7.3KB表示references/cost-audit.md3.2KB表示references/cur-athena.md7.0KB表示references/deterministic-calculations.md2.5KB 表示 references/ebs-optimization.md2.7KB 表示 references/ec2-rightsizing.md3.2KB 表示 references/pricing-lookup.md3.8KB 表示 references/rds-optimization.md1.8KB 表示 references/service-optimization.md2.9KBViewSKILL.md8.8KBViewreferences/budgets.md2.3KBViewreferences/cost-optimization-hub.md7.1KBViewreferences/free-tier.md1.6KB 参照を表示/reserved-instances.md2.3KB 参照を表示/lambda-optimization.md2.1KB 参照を表示/savings-plans.md3.3 KB 参照を表示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/
すべてのファイル
0件のファイルaws-billing-and-cost-managementをインストール
スキルファイルをダウンロードし、.claude/skills/ ディレクトリに解凍してください。
ZIPをダウンロードリポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。
git clone https://github.com/aws/agent-toolkit-for-aws/blob/main/skills/core-skills/aws-billing-and-cost-management/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
コピー





家
