|
| 1 | +resource "aws_ssm_parameter" "billing_alert_subscribers" { |
| 2 | + name = "${var.project}-billing-subscribers" |
| 3 | + type = "StringList" |
| 4 | + |
| 5 | +} |
| 6 | + |
| 7 | +data "aws_ssm_parameter" "billing_alert_subscribers" { |
| 8 | + name = aws_ssm_parameter.billing_alert_subscribers.name |
| 9 | +} |
| 10 | + |
| 11 | +resource "aws_budgets_budget" "cpm_budget" { |
| 12 | + name = "${var.project}-monthly-budget-${var.environment}" |
| 13 | + budget_type = "COST" |
| 14 | + limit_amount = var.limit |
| 15 | + limit_unit = "USD" |
| 16 | + time_unit = "MONTHLY" |
| 17 | + |
| 18 | + notification { |
| 19 | + comparison_operator = "GREATER_THAN" |
| 20 | + threshold = 50 |
| 21 | + threshold_type = "PERCENTAGE" |
| 22 | + notification_type = "ACTUAL" |
| 23 | + subscriber_email_addresses = split(",", data.aws_ssm_parameter.billing_alert_subscribers.value) |
| 24 | + } |
| 25 | + |
| 26 | + notification { |
| 27 | + comparison_operator = "GREATER_THAN" |
| 28 | + threshold = 75 |
| 29 | + threshold_type = "PERCENTAGE" |
| 30 | + notification_type = "ACTUAL" |
| 31 | + subscriber_email_addresses = split(",", data.aws_ssm_parameter.billing_alert_subscribers.value) |
| 32 | + } |
| 33 | + |
| 34 | + notification { |
| 35 | + comparison_operator = "GREATER_THAN" |
| 36 | + threshold = 90 |
| 37 | + threshold_type = "PERCENTAGE" |
| 38 | + notification_type = "ACTUAL" |
| 39 | + subscriber_email_addresses = split(",", data.aws_ssm_parameter.billing_alert_subscribers.value) |
| 40 | + } |
| 41 | + |
| 42 | + notification { |
| 43 | + comparison_operator = "GREATER_THAN" |
| 44 | + threshold = 100 |
| 45 | + threshold_type = "PERCENTAGE" |
| 46 | + notification_type = "ACTUAL" |
| 47 | + subscriber_email_addresses = split(",", data.aws_ssm_parameter.billing_alert_subscribers.value) |
| 48 | + } |
| 49 | +} |
0 commit comments