From 3fb1fefcaef0f84a810dbeed49478ced881c87a2 Mon Sep 17 00:00:00 2001 From: Andrey Devyatkin Date: Wed, 20 Nov 2024 10:47:36 +0000 Subject: [PATCH] enabled historical adjustment for the budget Signed-off-by: Andrey Devyatkin --- modules/budget_alerts/main.tf | 11 +++++++++++ modules/budget_alerts/variables.tf | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/modules/budget_alerts/main.tf b/modules/budget_alerts/main.tf index b375db8..3693569 100644 --- a/modules/budget_alerts/main.tf +++ b/modules/budget_alerts/main.tf @@ -28,6 +28,17 @@ resource "aws_budgets_budget" "this" { time_period_start = var.time_period_start time_unit = var.time_unit + dynamic "auto_adjust_data" { + for_each = var.auto_adjust ? toset(["auto_adjust"]) : toset([]) + content { + auto_adjust_type = "HISTORICAL" + + historical_options { + budget_adjustment_period = var.budget_adjustment_period + } + } + } + dynamic "notification" { for_each = merge(local.actual_notifications, local.forecasted_notifications) content { diff --git a/modules/budget_alerts/variables.tf b/modules/budget_alerts/variables.tf index 81a50f5..50179cd 100644 --- a/modules/budget_alerts/variables.tf +++ b/modules/budget_alerts/variables.tf @@ -50,3 +50,15 @@ variable "notification_on_threshold_percentage" { default = [100, 150, 200] description = "(Optional) The percentage of the budget threshold to notify. With default values, notifications will be sent at 100%, 150%, and 200% of the budget `limit_amount`." } + +variable "auto_adjust" { + type = bool + default = true + description = "Auto adjust budget based on historical values" +} + +variable "budget_adjustment_period" { + type = number + default = 6 + description = "Number of month to look back for historical values" +}