From e876552733b04f52f23e99572cba74f25cfd5f70 Mon Sep 17 00:00:00 2001 From: John Ake Date: Fri, 23 Aug 2024 15:35:52 +0100 Subject: [PATCH] Add statuscake heartbeat check --- monitoring/statuscake/resources.tf | 12 ++++++++++++ monitoring/statuscake/tfdocs.md | 7 ++++++- monitoring/statuscake/variables.tf | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/monitoring/statuscake/resources.tf b/monitoring/statuscake/resources.tf index 3b4d9fe..db1f755 100644 --- a/monitoring/statuscake/resources.tf +++ b/monitoring/statuscake/resources.tf @@ -21,6 +21,18 @@ resource "statuscake_uptime_check" "main" { } } +resource "statuscake_heartbeat_check" "main" { + for_each = toset(var.heartbeat_names) + + name = each.value + period = var.heartbeat_period + contact_groups = var.contact_groups +} + +output "heartbeat_check_urls" { + value = { for name in var.heartbeat_names : name => statuscake_heartbeat_check.main[name].check_url } +} + resource "statuscake_ssl_check" "main" { for_each = toset(var.ssl_urls) diff --git a/monitoring/statuscake/tfdocs.md b/monitoring/statuscake/tfdocs.md index 5fac412..7f948e0 100644 --- a/monitoring/statuscake/tfdocs.md +++ b/monitoring/statuscake/tfdocs.md @@ -16,6 +16,7 @@ No modules. | Name | Type | |------|------| +| [statuscake_heartbeat_check.main](https://registry.terraform.io/providers/StatusCakeDev/statuscake/latest/docs/resources/heartbeat_check) | resource | | [statuscake_ssl_check.main](https://registry.terraform.io/providers/StatusCakeDev/statuscake/latest/docs/resources/ssl_check) | resource | | [statuscake_uptime_check.main](https://registry.terraform.io/providers/StatusCakeDev/statuscake/latest/docs/resources/uptime_check) | resource | @@ -25,9 +26,13 @@ No modules. |------|-------------|------|---------|:--------:| | [confirmation](#input\_confirmation) | Retry the check when an error is detected to avoid false positives and micro downtimes | `number` | `2` | no | | [contact\_groups](#input\_contact\_groups) | Contact groups for the alerts | `list(string)` | `[]` | no | +| [heartbeat\_names](#input\_heartbeat\_names) | List of names for the heartbeat checks | `list(string)` | `[]` | no | +| [heartbeat\_period](#input\_heartbeat\_period) | The period in seconds within which a heartbeat must be received | `number` | `600` | no | | [ssl\_urls](#input\_ssl\_urls) | Set of URLs to perform SSL checks on | `list(string)` | `[]` | no | | [uptime\_urls](#input\_uptime\_urls) | Set of URLs to perform uptime checks on | `list(string)` | `[]` | no | ## Outputs -No outputs. +| Name | Description | +|------|-------------| +| [heartbeat\_check\_urls](#output\_heartbeat\_check\_urls) | n/a | diff --git a/monitoring/statuscake/variables.tf b/monitoring/statuscake/variables.tf index 7cc7d35..d41d1d4 100644 --- a/monitoring/statuscake/variables.tf +++ b/monitoring/statuscake/variables.tf @@ -25,3 +25,17 @@ variable "confirmation" { description = "Retry the check when an error is detected to avoid false positives and micro downtimes" default = 2 } + +# Heartbeat check variables +variable "heartbeat_names" { + type = list(string) + nullable = false + description = "List of names for the heartbeat checks" + default = [] +} + +variable "heartbeat_period" { + description = "The period in seconds within which a heartbeat must be received" + type = number + default = 600 +}