Hello guys!
I’m trying to add budget, cost monitoring and budget to Terraform. I have a folder modules which has the module monitoring. In variables.tf I have defined the needed variables and in main.tf I have the resources.
This is the code that I have in main.tf:
resource "google_monitoring_notification_channel" "email" {
# project = var.project
count = length(var.notified_mails)
display_name = "cloud function error email notification"
type = "email"
labels = {
email_address = var.notified_mails[count.index]
}
enabled = true
}
resource "google_billing_budget" "monthly_budget" {
billing_account = var.billing_account
display_name = "Monthly Expense Control"
budget_amount {
specified_amount {
currency_code = var.budget_amount.currency_code
units = var.budget_amount.units
}
}
calendar_period = var.calendar_period
threshold_rules {
threshold_percent = var.threshold_rules.threshold_percent
spend_basis = var.threshold_rules.spend_basis
}
notifications {
monitoring_notification_channels = [google_monitoring_notification_channel.email[*].name]
pubsub_topic = null
}
}
Then I have folders for each environments which have main.tf, variables.tf and config.auto.tfvars files. The notifications in each environment are defined like:
variable "notifications" {
type = object({
monitoring_notification_channels = list(string)
pubsub_topic = string
})
}
I get those errors:
Can someone help me please? Thank you in advance!