Slide 22
Slide 22 text
APPENDIX · A1 / DEEP DIVE
入力 — EventBridge → Cost Explorer → Bedrock A1
異常 単体 ではなく、過去 14日の推移 をセットで渡す
REGION
us-east-1 固定
RUNTIME
Python 3.12 / 60s
CE API
GetCostAndUsage
WINDOW
~14d × DAILY
EVENTBRIDGE から抽出する 5項目
account_id detail.accountId
無ければ rootCauses[0].linkedAccount
service rootCauses[0].service
例: Amazon GuardDuty
usage_type rootCauses[0].usageType
region rootCauses[0].region
total_impact impact.totalImpact · USD
制約 · CAD の EventBridge イベントは us-east-1 でのみ発行 。
Lambda・SSM も同リージョンに置く。
COST EXPLORER CALL
handler.py · _get_cost_trend() python
ce_client.get_cost_and_usage(
TimePeriod={"Start": start_14d, "End": today},
Granularity="DAILY",
Filter={"And": [
{"Dimensions": {"Key": "LINKED_ACCOUNT",
"Values": [account_id]}},
{"Dimensions": {"Key": "SERVICE",
"Values": [service]}},
]},
Metrics=["UnblendedCost"],
)
# → [{"date": "2026-05-01", "cost": 0.06}, //.] x14
Next · このコンテキストを プロンプト4セクション (アラート内容 / 14日推移 / 判断基準 / 出力フォーマット)に
組み立てる → 次スライド