From aecc3c2b91f180be68882e3f9db2804622e65b90 Mon Sep 17 00:00:00 2001
From: Paul Rudin <pr414@cam.ac.uk>
Date: Tue, 4 Aug 2020 12:50:29 +0100
Subject: [PATCH] add enabled toggle on alerting policy

---
 main.tf                         | 1 +
 modules/monitoring/main.tf      | 1 +
 modules/monitoring/variables.tf | 6 ++++++
 variables.tf                    | 6 ++++++
 4 files changed, 14 insertions(+)

diff --git a/main.tf b/main.tf
index 6681eba..892125d 100644
--- a/main.tf
+++ b/main.tf
@@ -146,4 +146,5 @@ module "uptime_monitoring" {
   monitored_domain = var.dns_name
   uptime_timeout   = var.alerting_uptime_timeout
   uptime_period    = var.alerting_uptime_period
+  enabled          = var.alerting_enabled
 }
diff --git a/modules/monitoring/main.tf b/modules/monitoring/main.tf
index d624d43..09c8db9 100644
--- a/modules/monitoring/main.tf
+++ b/modules/monitoring/main.tf
@@ -49,6 +49,7 @@ resource "google_monitoring_notification_channel" "notification_email" {
 }
 
 resource "google_monitoring_alert_policy" "uptime_alert" {
+  enabled               = var.enabled
   count                 = local.count
   project               = var.project
   display_name          = "HTTP uptime alert"
diff --git a/modules/monitoring/variables.tf b/modules/monitoring/variables.tf
index d71429d..1f54f74 100644
--- a/modules/monitoring/variables.tf
+++ b/modules/monitoring/variables.tf
@@ -31,3 +31,9 @@ variable "uptime_period" {
   default     = "300s"
   description = "Frequency of uptime checks"
 }
+
+variable "enabled" {
+  type        = bool
+  default     = true
+  description = "Whether the alerting policy is enabled"
+}
diff --git a/variables.tf b/variables.tf
index d903a8c..2541bc3 100644
--- a/variables.tf
+++ b/variables.tf
@@ -105,3 +105,9 @@ variable "alerting_uptime_period" {
   default     = "300s"
   description = "Frequency of uptime checks"
 }
+
+variable "alerting_enabled" {
+  type        = boolean
+  default     = true
+  description = "Whether alerting policy is enabled"
+}
-- 
GitLab