diff --git a/blueprints/cloud-operations/quota-monitoring/main.tf b/blueprints/cloud-operations/quota-monitoring/main.tf index 0a4de23ba..0593f4fd1 100644 --- a/blueprints/cloud-operations/quota-monitoring/main.tf +++ b/blueprints/cloud-operations/quota-monitoring/main.tf @@ -106,34 +106,36 @@ resource "google_project_iam_member" "quota_viewer" { member = module.cf.service_account_iam_email } -resource "google_monitoring_alert_policy" "alert_policy" { - project = module.project.project_id - display_name = "Quota monitor" - combiner = "OR" - conditions { - display_name = "simple quota threshold for cpus utilization" - condition_threshold { - filter = "metric.type=\"custom.googleapis.com/quota/cpus_utilization\" resource.type=\"global\"" - threshold_value = 0.75 - comparison = "COMPARISON_GT" - duration = "0s" - aggregations { - alignment_period = "60s" - group_by_fields = [] - per_series_aligner = "ALIGN_MEAN" - } - trigger { - count = 1 - percent = 0 +var.create_alert ? { + resource "google_monitoring_alert_policy" "alert_policy" { + project = module.project.project_id + display_name = "Quota monitor" + combiner = "OR" + conditions { + display_name = "simple quota threshold for cpus utilization" + condition_threshold { + filter = "metric.type=\"custom.googleapis.com/quota/cpus_utilization\" resource.type=\"global\"" + threshold_value = 0.75 + comparison = "COMPARISON_GT" + duration = "0s" + aggregations { + alignment_period = "60s" + group_by_fields = [] + per_series_aligner = "ALIGN_MEAN" + } + trigger { + count = 1 + percent = 0 + } } } - } - enabled = false - user_labels = { - name = var.name - } - documentation { - content = "GCE cpus quota over threshold." + enabled = false + user_labels = { + name = var.name + } + documentation { + content = "GCE cpus quota over threshold." + } } } diff --git a/blueprints/cloud-operations/quota-monitoring/variables.tf b/blueprints/cloud-operations/quota-monitoring/variables.tf index 2b69aa1cb..cce24ca40 100644 --- a/blueprints/cloud-operations/quota-monitoring/variables.tf +++ b/blueprints/cloud-operations/quota-monitoring/variables.tf @@ -20,6 +20,12 @@ variable "bundle_path" { default = "./bundle.zip" } +variable "create_alert" { + description = "Enables the creation of a sample monitoring alert, false by default." + type = bool + default = false +} + variable "name" { description = "Arbitrary string used to name created resources." type = string