From 8a17e052c5668f4f7c62780a4554a031e1c48688 Mon Sep 17 00:00:00 2001 From: Ash Davies <3853061+DrizzlyOwl@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:22:46 +0100 Subject: [PATCH] Deploy StatusCake SSL Checks for public endpoints --- terraform/.terraform.lock.hcl | 23 +++++++++++++++++++++ terraform/README.md | 7 +++++++ terraform/locals.tf | 4 ++++ terraform/providers.tf | 4 ++++ terraform/statuscake-tls-monitor.tf | 11 ++++++++++ terraform/variables.tf | 31 +++++++++++++++++++++++++++++ terraform/versions.tf | 4 ++++ 7 files changed, 84 insertions(+) create mode 100644 terraform/statuscake-tls-monitor.tf diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl index b58f57a6e..4e9c5a8bd 100644 --- a/terraform/.terraform.lock.hcl +++ b/terraform/.terraform.lock.hcl @@ -78,3 +78,26 @@ provider "registry.terraform.io/hashicorp/null" { "zh:fca01a623d90d0cad0843102f9b8b9fe0d3ff8244593bd817f126582b52dd694", ] } + +provider "registry.terraform.io/statuscakedev/statuscake" { + version = "2.2.1" + constraints = ">= 2.1.0" + hashes = [ + "h1:v9Zsszr6aXmjl0Zf6XfN+qOlIo+fJJL7iV1YLXuF/78=", + "zh:1c3e89cf19118fc07d7b04257251fc9897e722c16e0a0df7b07fcd261f8c12e7", + "zh:443c840fd4ea0c7e8a45197c4823e7b122f087c7fac4f6ea96e9df1c499b9a39", + "zh:5c4a0f20dc321d45ba24207db0d21509a99a0531e150d989bf81c77ff3492ad1", + "zh:631e1bcab1703d6b722aeed3b709815575655b6bd28fca6ed48af64ee9205949", + "zh:6670e7dd4ac0a7e1ebb7370ad18d4a6d26a991602a138ba536538aa3b8a1cbc7", + "zh:6fa0b4200f08e088e382221095b75614e2a710e0185d28282a467a64fea84e3e", + "zh:8acff0f15c098f94643f0ecf7d3302f266869a53d97f7f647c8429d2b94f7ec1", + "zh:9007669557420a006ccbe7d03b1fb447a7a2770bde0db15909e0df63a89b936d", + "zh:93f0a45edbd4b851edca0ab49329a1de69261c26ac981c2aec985045bd60cf46", + "zh:99084f140c2be88b2554853fb5382f753e6809dadaa97b289f7cc92259c0d4d9", + "zh:d046b0d8b9fc512b3b483731f17edd8ee221f1dcaec649a8b8dcdde5400a90c4", + "zh:d0c966677d7a073d21605b351f2b3a83174901bcb6f25d4b4eb5b7822dac2d05", + "zh:dbd5ebfa764c0b58e764721704524c4f7028e70c8cb0b22efe494d588bf65cc0", + "zh:e492bdc2ddd32fe73532566affd6a9a22c0b75c042583d5450881f6c523441f8", + "zh:ee8f95766dbc1e1d2c41c6c837582af16b3e7ed5698c23471f1376011c7fa1a7", + ] +} diff --git a/terraform/README.md b/terraform/README.md index 9334784d1..4f1ef70ee 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -126,6 +126,7 @@ If everything looks good, answer `yes` and wait for the new infrastructure to be |------|---------| | [terraform](#requirement\_terraform) | >= 1.6.1 | | [azurerm](#requirement\_azurerm) | >= 3.76.0 | +| [statuscake](#requirement\_statuscake) | >= 2.1.0 | ## Providers @@ -137,6 +138,7 @@ No providers. |------|--------|---------| | [azure\_container\_apps\_hosting](#module\_azure\_container\_apps\_hosting) | github.com/DFE-Digital/terraform-azurerm-container-apps-hosting | v1.1.0 | | [azurerm\_key\_vault](#module\_azurerm\_key\_vault) | github.com/DFE-Digital/terraform-azurerm-key-vault-tfvars | v0.2.2 | +| [statuscake-tls-monitor](#module\_statuscake-tls-monitor) | github.com/dfe-digital/terraform-statuscake-tls-monitor | v0.1.2 | ## Resources @@ -178,6 +180,11 @@ No resources. | [monitor\_email\_receivers](#input\_monitor\_email\_receivers) | A list of email addresses that should be notified by monitoring alerts | `list(string)` | n/a | yes | | [monitor\_endpoint\_healthcheck](#input\_monitor\_endpoint\_healthcheck) | Specify a route that should be monitored for a 200 OK status | `string` | n/a | yes | | [project\_name](#input\_project\_name) | Project name. Will be used along with `environment` as a prefix for all resources. | `string` | n/a | yes | +| [statuscake\_api\_token](#input\_statuscake\_api\_token) | API token for StatusCake | `string` | `"00000000000000000000000000000"` | no | +| [statuscake\_contact\_group\_email\_addresses](#input\_statuscake\_contact\_group\_email\_addresses) | List of email address that should receive notifications from StatusCake | `list(string)` | `[]` | no | +| [statuscake\_contact\_group\_integrations](#input\_statuscake\_contact\_group\_integrations) | List of Integration IDs to connect to your Contact Group | `list(string)` | `[]` | no | +| [statuscake\_contact\_group\_name](#input\_statuscake\_contact\_group\_name) | Name of the contact group in StatusCake | `string` | `""` | no | +| [statuscake\_monitored\_resource\_addresses](#input\_statuscake\_monitored\_resource\_addresses) | The URLs to perform TLS checks on | `list(string)` | `[]` | no | | [tags](#input\_tags) | Tags to be applied to all resources | `map(string)` | n/a | yes | | [tfvars\_filename](#input\_tfvars\_filename) | tfvars filename. This file is uploaded and stored encrupted within Key Vault, to ensure that the latest tfvars are stored in a shared place. | `string` | n/a | yes | | [virtual\_network\_address\_space](#input\_virtual\_network\_address\_space) | Virtual network address space CIDR | `string` | n/a | yes | diff --git a/terraform/locals.tf b/terraform/locals.tf index ac6a652f9..73224205d 100644 --- a/terraform/locals.tf +++ b/terraform/locals.tf @@ -34,4 +34,8 @@ locals { existing_logic_app_workflow = var.existing_logic_app_workflow existing_network_watcher_name = var.existing_network_watcher_name existing_network_watcher_resource_group_name = var.existing_network_watcher_resource_group_name + statuscake_monitored_resource_addresses = var.statuscake_monitored_resource_addresses + statuscake_contact_group_name = var.statuscake_contact_group_name + statuscake_contact_group_integrations = var.statuscake_contact_group_integrations + statuscake_contact_group_email_addresses = var.statuscake_contact_group_email_addresses } diff --git a/terraform/providers.tf b/terraform/providers.tf index 6b537105e..c06a45c29 100644 --- a/terraform/providers.tf +++ b/terraform/providers.tf @@ -2,3 +2,7 @@ provider "azurerm" { features {} skip_provider_registration = true } + +provider "statuscake" { + api_token = var.statuscake_api_token +} diff --git a/terraform/statuscake-tls-monitor.tf b/terraform/statuscake-tls-monitor.tf new file mode 100644 index 000000000..02a9b0af4 --- /dev/null +++ b/terraform/statuscake-tls-monitor.tf @@ -0,0 +1,11 @@ +module "statuscake-tls-monitor" { + source = "github.com/dfe-digital/terraform-statuscake-tls-monitor?ref=v0.1.2" + + statuscake_monitored_resource_addresses = local.statuscake_monitored_resource_addresses + statuscake_alert_at = [ # days to alert on + 14, 7, 3 + ] + statuscake_contact_group_name = local.statuscake_contact_group_name + statuscake_contact_group_integrations = local.statuscake_contact_group_integrations + statuscake_contact_group_email_addresses = local.statuscake_contact_group_email_addresses +} diff --git a/terraform/variables.tf b/terraform/variables.tf index 2ec69e7d0..e26412e59 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -195,3 +195,34 @@ variable "eventhub_export_log_analytics_table_names" { type = list(string) default = [] } + +variable "statuscake_api_token" { + description = "API token for StatusCake" + type = string + sensitive = true + default = "00000000000000000000000000000" +} + +variable "statuscake_contact_group_name" { + description = "Name of the contact group in StatusCake" + type = string + default = "" +} + +variable "statuscake_contact_group_integrations" { + description = "List of Integration IDs to connect to your Contact Group" + type = list(string) + default = [] +} + +variable "statuscake_monitored_resource_addresses" { + description = "The URLs to perform TLS checks on" + type = list(string) + default = [] +} + +variable "statuscake_contact_group_email_addresses" { + description = "List of email address that should receive notifications from StatusCake" + type = list(string) + default = [] +} diff --git a/terraform/versions.tf b/terraform/versions.tf index 3c6f1fc54..b13f6ce54 100644 --- a/terraform/versions.tf +++ b/terraform/versions.tf @@ -5,5 +5,9 @@ terraform { source = "hashicorp/azurerm" version = ">= 3.76.0" } + statuscake = { + source = "StatusCakeDev/statuscake" + version = ">= 2.1.0" + } } }