diff --git a/terraform/aks/statuscake.tf b/terraform/aks/statuscake.tf new file mode 100644 index 00000000..73236625 --- /dev/null +++ b/terraform/aks/statuscake.tf @@ -0,0 +1,29 @@ +module "statuscake" { + for_each = var.statuscake_alerts + + source = "./vendor/modules/aks//monitoring/statuscake" + + uptime_urls = each.value.website_url + contact_groups = each.value.contact_group +} + +resource "statuscake_ssl_check" "domain-alert" { + for_each = var.statuscake_alerts + + check_interval = 3600 # Check once per hour + contact_groups = each.value.contact_group + follow_redirects = true + + alert_config { + alert_at = [3, 7, 30] # Alert 1 month, 1 week then 3 days before expiration + + on_reminder = true + on_expiry = true + on_broken = true + on_mixed = true + } + + monitored_resource { + address = each.value.ssl_domain + } +} diff --git a/terraform/aks/variables.tf b/terraform/aks/variables.tf index 5f783a21..099be848 100644 --- a/terraform/aks/variables.tf +++ b/terraform/aks/variables.tf @@ -117,3 +117,11 @@ variable "review_url_redis_name" { default = null description = "the name of the secret storing review redis url" } + +# StatusCake variables +variable "statuscake_alerts" { + type = map(any) + default = {} +} + +variable "api_token" { default = "" } diff --git a/terraform/aks/workspace_variables/preproduction_aks.tfvars.json b/terraform/aks/workspace_variables/preproduction_aks.tfvars.json index 072b945e..09cb382c 100644 --- a/terraform/aks/workspace_variables/preproduction_aks.tfvars.json +++ b/terraform/aks/workspace_variables/preproduction_aks.tfvars.json @@ -7,5 +7,14 @@ "azure_resource_prefix": "s189t01", "config_short": "pp", "service_short": "faltrn", - "app_key_vault": "s189t01-faltrn-pp-app-kv" + "app_key_vault": "s189t01-faltrn-pp-app-kv", + "statuscake_alerts": { + "alert": { + "website_url": [ + "https://preprod.find-a-lost-trn.education.gov.uk/health/all", + "https://find-a-lost-trn-preproduction.test.teacherservices.cloud/health/all" + ], + "contact_group": [282783] + } + } } diff --git a/terraform/aks/workspace_variables/production_aks.tfvars.json b/terraform/aks/workspace_variables/production_aks.tfvars.json index c55ae080..a02b970e 100644 --- a/terraform/aks/workspace_variables/production_aks.tfvars.json +++ b/terraform/aks/workspace_variables/production_aks.tfvars.json @@ -8,5 +8,16 @@ "config_short": "pd", "service_short": "faltrn", "app_key_vault": "s189p01-faltrn-pd-app-kv", - "worker_replicas": 0 + "worker_replicas": 0, + "statuscake_alerts": { + "alert": { + "website_url": [ + "https://find-a-lost-trn.education.gov.uk/health/all", + "https://find-a-lost-trn-production.teacherservices.cloud/health/all" + ], + "contact_group": [282783], + "ssl_domain": "https://find-a-lost-trn.education.gov.uk", + "confirmations": 2 + } + } }