From f7e4fc9216ef05f6f90b4552f6c333a56e538062 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 10 Jul 2025 11:46:30 +0100 Subject: [PATCH 01/11] add athena budget alert --- terraform/core/34-aws-budget-alerting.tf | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 648249145..78d4256c0 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -9,3 +9,26 @@ module "set_budget_limit_amount" { account_id = data.aws_caller_identity.data_platform.account_id emails_to_notify = var.emails_to_notify_with_budget_alerts } + + +module "aws_budget" { + source = "github.com/LBHackney-IT/ce-aws-budgets-lbh" + + budget_name = "Athena Daily Budget Alert" + budget_type = "COST" + limit_amount = "3" + time_unit = "DAILY" + + cost_filter = [ + { + name = "Service" + values = ["Amazon Athena"] + } + ] + + comparison_operator = "GREATER_THAN" + threshold = 100 + threshold_type = "PERCENTAGE" + notification_type = "ACTUAL" + subscriber_email_address = var.emails_to_notify_with_budget_alerts +} From c609832f1e1ed5467627139b2314706d83e05ea1 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 14:20:34 +0100 Subject: [PATCH 02/11] configure budget and anomaly subscriptions --- terraform/core/34-aws-budget-alerting.tf | 40 ++++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 78d4256c0..b91335947 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -10,14 +10,24 @@ module "set_budget_limit_amount" { emails_to_notify = var.emails_to_notify_with_budget_alerts } +resource "aws_ssm_parameter" "budget_alert_recipients" { + name = "budget-alert-recipients" + type = "StringList" + tags = var.tags +} + +data "aws_ssm_parameter" "budget_alert_recipients" { + name = aws_ssm_parameter.budget_alert_recipients.value +} module "aws_budget" { - source = "github.com/LBHackney-IT/ce-aws-budgets-lbh" + count = local.is_live_environment ? 1 : 0 + source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=d3a5e0e0751aafcc786dfcbd45af38ed9d834dec" - budget_name = "Athena Daily Budget Alert" - budget_type = "COST" - limit_amount = "3" - time_unit = "DAILY" + budget_name = "Athena Daily Budget Alert" + budget_type = "COST" + limit_amount = local.is_production_environment ? "3" : "1" + time_unit = "DAILY" cost_filter = [ { @@ -26,9 +36,19 @@ module "aws_budget" { } ] - comparison_operator = "GREATER_THAN" - threshold = 100 - threshold_type = "PERCENTAGE" - notification_type = "ACTUAL" - subscriber_email_address = var.emails_to_notify_with_budget_alerts + comparison_operator = "GREATER_THAN" + threshold = 100 + threshold_type = "PERCENTAGE" + notification_type = "ACTUAL" + subscriber_email_addresses = data.aws_ssm_parameter.budget_alert_recipients + + enable_anomaly_detection = true + anomaly_monitor_name = "AthenaDailyAnomalyMonitor" + anomaly_monitor_type = "DIMENSIONAL" + anomaly_monitor_dimension = "SERVICE" + anomaly_subscription_name = "AthenaDailySubscription" + anomaly_subscription_frequency = "DAILY" + threshold_key = "ANOMALY_TOTAL_IMPACT_ABSOLUTE" + match_options = ["GREATER_THAN_OR_EQUAL"] + threshold_values = ["1"] } From c546db62233cf8fc451a1718f9411dc87d5d6448 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 14:24:26 +0100 Subject: [PATCH 03/11] change commit ref --- terraform/core/34-aws-budget-alerting.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index b91335947..5143fed58 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -22,7 +22,7 @@ data "aws_ssm_parameter" "budget_alert_recipients" { module "aws_budget" { count = local.is_live_environment ? 1 : 0 - source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=d3a5e0e0751aafcc786dfcbd45af38ed9d834dec" + source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=671dab00698fbef054ebc15b7928e03aae525583" budget_name = "Athena Daily Budget Alert" budget_type = "COST" From 7d83982173de0642b4b2e414f03780557fe47257 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 14:30:20 +0100 Subject: [PATCH 04/11] add tags --- terraform/core/34-aws-budget-alerting.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 5143fed58..4f2d8aa67 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -13,7 +13,7 @@ module "set_budget_limit_amount" { resource "aws_ssm_parameter" "budget_alert_recipients" { name = "budget-alert-recipients" type = "StringList" - tags = var.tags + tags = module.tags.values } data "aws_ssm_parameter" "budget_alert_recipients" { @@ -23,6 +23,7 @@ data "aws_ssm_parameter" "budget_alert_recipients" { module "aws_budget" { count = local.is_live_environment ? 1 : 0 source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=671dab00698fbef054ebc15b7928e03aae525583" + tags = module.tags.values budget_name = "Athena Daily Budget Alert" budget_type = "COST" From 4b601f282ee78912419d06a1ee52ac2cc3ccca58 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 15:01:37 +0100 Subject: [PATCH 05/11] add Glue budget --- terraform/core/34-aws-budget-alerting.tf | 36 +++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 4f2d8aa67..ca20d7449 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -20,7 +20,7 @@ data "aws_ssm_parameter" "budget_alert_recipients" { name = aws_ssm_parameter.budget_alert_recipients.value } -module "aws_budget" { +module "aws_budget_athena" { count = local.is_live_environment ? 1 : 0 source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=671dab00698fbef054ebc15b7928e03aae525583" tags = module.tags.values @@ -53,3 +53,37 @@ module "aws_budget" { match_options = ["GREATER_THAN_OR_EQUAL"] threshold_values = ["1"] } + +module "aws_budget_glue" { + count = local.is_live_environment ? 1 : 0 + source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=671dab00698fbef054ebc15b7928e03aae525583" + tags = module.tags.values + + budget_name = "Glue Daily Budget Alert" + budget_type = "COST" + limit_amount = local.is_production_environment ? "45" : "15" + time_unit = "DAILY" + + cost_filter = [ + { + name = "Service" + values = ["Amazon Glue"] + } + ] + + comparison_operator = "GREATER_THAN" + threshold = 100 + threshold_type = "PERCENTAGE" + notification_type = "ACTUAL" + subscriber_email_addresses = data.aws_ssm_parameter.budget_alert_recipients + + enable_anomaly_detection = true + anomaly_monitor_name = "AthenaDailyAnomalyMonitor" + anomaly_monitor_type = "DIMENSIONAL" + anomaly_monitor_dimension = "SERVICE" + anomaly_subscription_name = "AthenaDailySubscription" + anomaly_subscription_frequency = "DAILY" + threshold_key = "ANOMALY_TOTAL_IMPACT_ABSOLUTE" + match_options = ["GREATER_THAN_OR_EQUAL"] + threshold_values = ["1"] +} From f2efaa52ce955637029f924417540ed7229f8a79 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 15:02:49 +0100 Subject: [PATCH 06/11] change Athena limits --- terraform/core/34-aws-budget-alerting.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index ca20d7449..9bf21a206 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -27,7 +27,7 @@ module "aws_budget_athena" { budget_name = "Athena Daily Budget Alert" budget_type = "COST" - limit_amount = local.is_production_environment ? "3" : "1" + limit_amount = local.is_production_environment ? "5" : "3" time_unit = "DAILY" cost_filter = [ From 945ae797c8cf3709db6fb2468ecb2e6658d08e41 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 15:10:33 +0100 Subject: [PATCH 07/11] remove unsupported tags argument from budgets --- terraform/core/34-aws-budget-alerting.tf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 9bf21a206..1a27ccf26 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -23,7 +23,6 @@ data "aws_ssm_parameter" "budget_alert_recipients" { module "aws_budget_athena" { count = local.is_live_environment ? 1 : 0 source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=671dab00698fbef054ebc15b7928e03aae525583" - tags = module.tags.values budget_name = "Athena Daily Budget Alert" budget_type = "COST" @@ -57,7 +56,7 @@ module "aws_budget_athena" { module "aws_budget_glue" { count = local.is_live_environment ? 1 : 0 source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=671dab00698fbef054ebc15b7928e03aae525583" - tags = module.tags.values + budget_name = "Glue Daily Budget Alert" budget_type = "COST" From 2021a53e7d8b1cb571a35d96fc9e4b56aca8555d Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 15:15:24 +0100 Subject: [PATCH 08/11] set value argument --- terraform/core/34-aws-budget-alerting.tf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 1a27ccf26..5692b2b8b 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -11,9 +11,10 @@ module "set_budget_limit_amount" { } resource "aws_ssm_parameter" "budget_alert_recipients" { - name = "budget-alert-recipients" - type = "StringList" - tags = module.tags.values + name = "budget-alert-recipients" + type = "StringList" + value = "value" + tags = module.tags.values } data "aws_ssm_parameter" "budget_alert_recipients" { From e2fd94259346efe562c6b2e0126bdc98d92c8b6b Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 15:17:37 +0100 Subject: [PATCH 09/11] pin to release 1.4.0 --- terraform/core/34-aws-budget-alerting.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 5692b2b8b..0aba8f32e 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -23,7 +23,7 @@ data "aws_ssm_parameter" "budget_alert_recipients" { module "aws_budget_athena" { count = local.is_live_environment ? 1 : 0 - source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=671dab00698fbef054ebc15b7928e03aae525583" + source = "github.com/LBHackney-IT/ce-aws-budgets-lbh.git?ref=176a7e7234d74d94d5116c7f0b5d59f6e6db0a48" # v1.4.0 budget_name = "Athena Daily Budget Alert" budget_type = "COST" From 0a32b547e1cf1e5355ed5bd2ee0d80b85cc16eeb Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 15:29:34 +0100 Subject: [PATCH 10/11] change name of parameter --- terraform/core/34-aws-budget-alerting.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index 0aba8f32e..a30fb7ad0 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -11,7 +11,7 @@ module "set_budget_limit_amount" { } resource "aws_ssm_parameter" "budget_alert_recipients" { - name = "budget-alert-recipients" + name = "/data-and-insight/budget-alert-recipients" type = "StringList" value = "value" tags = module.tags.values From be3b5229c1307a763b83da8c6ba177e0568f8c0f Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 21 Aug 2025 15:34:54 +0100 Subject: [PATCH 11/11] add value attribute --- terraform/core/34-aws-budget-alerting.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terraform/core/34-aws-budget-alerting.tf b/terraform/core/34-aws-budget-alerting.tf index a30fb7ad0..42566bede 100644 --- a/terraform/core/34-aws-budget-alerting.tf +++ b/terraform/core/34-aws-budget-alerting.tf @@ -41,7 +41,7 @@ module "aws_budget_athena" { threshold = 100 threshold_type = "PERCENTAGE" notification_type = "ACTUAL" - subscriber_email_addresses = data.aws_ssm_parameter.budget_alert_recipients + subscriber_email_addresses = [data.aws_ssm_parameter.budget_alert_recipients.value] enable_anomaly_detection = true anomaly_monitor_name = "AthenaDailyAnomalyMonitor" @@ -75,7 +75,7 @@ module "aws_budget_glue" { threshold = 100 threshold_type = "PERCENTAGE" notification_type = "ACTUAL" - subscriber_email_addresses = data.aws_ssm_parameter.budget_alert_recipients + subscriber_email_addresses = [data.aws_ssm_parameter.budget_alert_recipients.value] enable_anomaly_detection = true anomaly_monitor_name = "AthenaDailyAnomalyMonitor"