AWS Cost Management でコストをモニタリングし最適化する
awsAWS Cost Managementは コストのモニタリングや予測、最適化のための機能群。 Billing にもレポートなど類似の機能があるが、 Billing が 現在のコストを管理するための機能群なのに対して、Cost Management は将来のコストをターゲットとしているようだ。
Cost Explorer
Cost Explorer は サービスやリージョンごとのコストや予測値をタグなどでフィルタして表示することができる機能。
Usage type filter でフィルタすれば ELB や EC2 のデータ転送にかかっているコストを 見ることができる。
Budgets
Budgets は設定した予算を超過した際にSNSなどに通知したり、定期的にメールでレポートを送ったりすることができる機能。
CDK では次のように予算を設定できる。 現状 L2 Constructs がないので CFn の AWS::Budgets::Budget のドキュメントを見ながら書く。
import * as budgets from 'aws-cdk-lib/aws-budgets';
new budgets.CfnBudget(this, 'TestBudget', {
budget: {
budgetName: "testbudget2",
budgetLimit: {
amount: 60,
unit: "USD"
},
timeUnit: "MONTHLY",
budgetType: "COST",
costFilters: {
Region: ["ap-northeast-1"]
}
},
notificationsWithSubscribers: [
{
notification: {
notificationType: "ACTUAL",
comparisonOperator: "GREATER_THAN",
threshold: 99
},
subscribers: [
{
subscriptionType: "EMAIL",
address: "[email protected]"
},
]
}
]
})
Cost Anomaly Detection
Cost Anomaly Detection は通常よりもコストが高くなっているサービスをメールなどで通知してくれる機能。
Rightsizing Recommendations
Rightsizing Recommendations は リソースが十分活用されてない EC2 インスタンスと、タイプを変更することによる節約額を表示してくれる機能。 AWS Cost Management > Preferences から Receive Amazon EC2 resource recommendations にチェックを入れると有効になる。