-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbudget.tf
More file actions
38 lines (31 loc) · 1.62 KB
/
budget.tf
File metadata and controls
38 lines (31 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Budget resource to monitor and control spending in the OCI tenancy
# This acts as a safety net for "Always Free" accounts to prevent unexpected charges.
resource "oci_budget_budget" "free_tier_safety" {
# Monitoring the root compartment (Tenancy) to capture all usage across the account
compartment_id = var.tenancy_ocid
amount = 1 # Budget limit set to $1
reset_period = "MONTHLY" # Budget resets every month
target_type = "COMPARTMENT"
targets = [var.tenancy_ocid]
display_name = "Always-Free-Safety-Budget"
description = "Alert me if I spend more than $1 to avoid unexpected PAYG charges."
}
# Alert Rule 1: Triggered when ACTUAL spending reaches a threshold
resource "oci_budget_alert_rule" "actual_spend_alert" {
budget_id = oci_budget_budget.free_tier_safety.id
threshold = 100 # 100% of the budget amount ($1)
threshold_type = "PERCENTAGE"
type = "ACTUAL" # Based on actual money spent
recipients = var.alert_email
message = "WARNING: You have actually spent $1 this month. Check your OCI resources!"
}
# Alert Rule 2: Triggered when FORECASTED spending reaches a threshold
# This provides earlier warning if current usage trends suggest the budget will be exceeded.
resource "oci_budget_alert_rule" "forecast_spend_alert" {
budget_id = oci_budget_budget.free_tier_safety.id
threshold = 100 # 100% of the budget amount ($1)
threshold_type = "PERCENTAGE"
type = "FORECAST" # Based on predicted spending by the end of the period
recipients = var.alert_email
message = "WARNING: Oracle predicts you will spend $1 by the end of the month."
}