From 79bd4ff7bcb4966fe2359505328abd6dd0573b98 Mon Sep 17 00:00:00 2001 From: Ben Larabie Date: Thu, 19 Dec 2024 14:11:00 -0500 Subject: [PATCH] Add a budget alert for when we use a lot of cloudwatch data scanning (#1704) * Formatting [review] * type --- aws/common/budget.tf | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/aws/common/budget.tf b/aws/common/budget.tf index 9373c7a27..2befba153 100644 --- a/aws/common/budget.tf +++ b/aws/common/budget.tf @@ -23,6 +23,38 @@ resource "aws_budgets_budget" "notify_global" { } } +resource "aws_budgets_budget" "cloudwatch_data_scanned" { + name = "cloudwatch-data-scanned-budget" + budget_type = "USAGE" + limit_amount = "10000" + limit_unit = "GB" + time_unit = "DAILY" + + cost_filter { + name = "UsageType" + values = [ + "CAN1-DataScanned-Bytes", + ] + } + + notification { + comparison_operator = "GREATER_THAN" + threshold = 100 + threshold_type = "PERCENTAGE" + notification_type = "ACTUAL" + subscriber_sns_topic_arns = [aws_sns_topic.notification-canada-ca-alert-general.arn] + } + + notification { + comparison_operator = "GREATER_THAN" + threshold = 80 + threshold_type = "PERCENTAGE" + notification_type = "ACTUAL" + subscriber_sns_topic_arns = [aws_sns_topic.notification-canada-ca-alert-general.arn] + } + +} + module "budget_notifier" { source = "github.com/cds-snc/terraform-modules//spend_notifier?ref=v9.6.4" daily_spend_notifier_hook = var.budget_sre_bot_webhook