locals {
environments = {
production = {
budget_limit = 20000
alert_thresholds = [50, 75, 90, 95, 100, 110]
emails = ["finance@example.com", "cto@example.com", "prod-ops@example.com"]
}
staging = {
budget_limit = 3000
alert_thresholds = [75, 100]
emails = ["dev-ops@example.com"]
}
development = {
budget_limit = 1000
alert_thresholds = [80, 100, 150]
emails = ["dev-team@example.com"]
}
}
}
module "env_budgets" {
for_each = local.environments
source = "registry.patterneddesigns.ca/governance/cost-controls/aws"
version = "1.2.0"
budget_name = "${each.key}-monthly-budget"
budget_limit = each.value.budget_limit
alert_thresholds = each.value.alert_thresholds
notification_emails = each.value.emails
cost_filters = {
TagKeyValue = ["Environment$${each.key}"]
}
}
# Outputs for each environment budget
output "budget_arns" {
description = "ARNs of all environment budgets"
value = { for k, v in module.env_budgets : k => v.budget_arn }
}