From 489e6e80ba37360289cf0d1f4af0cc4bb9c9e018 Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Tue, 13 Feb 2024 10:56:24 -0500 Subject: [PATCH 1/5] Remerged --- azure/main.tf | 8 ++++++++ azure/tf-smoketest-variables.tf | 1 + azure/user_vars.auto.tfvars | 2 ++ azure/variables.tf | 11 +++++++++++ ipa.tf | 10 ++++++++++ main.tf | 18 +++++++++++++----- tf-smoketest-variables.tf | 1 + user_vars.auto.tfvars | 2 ++ variables.tf | 15 ++++++++++++++- 9 files changed, 62 insertions(+), 6 deletions(-) diff --git a/azure/main.tf b/azure/main.tf index aa3eb88a..b007a5a3 100644 --- a/azure/main.tf +++ b/azure/main.tf @@ -39,9 +39,17 @@ terraform { source = "hashicorp/vault" version = "3.13.0" } + statuscake = { + source = "StatusCakeDev/statuscake" + version = "2.2.2" + } } } +provider "statuscake" { + api_token = var.statuscake_api_key +} + provider "azurerm" { features { cognitive_account { diff --git a/azure/tf-smoketest-variables.tf b/azure/tf-smoketest-variables.tf index eefa53f9..8e327a8b 100644 --- a/azure/tf-smoketest-variables.tf +++ b/azure/tf-smoketest-variables.tf @@ -103,6 +103,7 @@ resource "kubernetes_config_map" "terraform-variables" { thanos_enabled = "${jsonencode(var.thanos_enabled)}" harness_delegate = "${jsonencode(var.harness_delegate)}" harness_mount_path = "${jsonencode(var.harness_mount_path)}" + statuscake_enabled = "${jsonencode(var.statuscake_enabled)}" } } diff --git a/azure/user_vars.auto.tfvars b/azure/user_vars.auto.tfvars index 28a45e84..c234cc37 100644 --- a/azure/user_vars.auto.tfvars +++ b/azure/user_vars.auto.tfvars @@ -139,3 +139,5 @@ additional_node_pools = { cluster_auto_scaling_max_count = 1 } } + +statuscake_enabled = true diff --git a/azure/variables.tf b/azure/variables.tf index 4eb791bb..43d93ea7 100644 --- a/azure/variables.tf +++ b/azure/variables.tf @@ -648,3 +648,14 @@ variable "harness_mount_path" { type = string default = "harness" } + +variable "statuscake_enabled" { + type = bool + default = false +} + +variable "statuscake_api_key" { + type = string + sensitive = true + default = "" +} diff --git a/ipa.tf b/ipa.tf index cad4f945..7a33b319 100644 --- a/ipa.tf +++ b/ipa.tf @@ -313,6 +313,16 @@ module "secrets-operator-setup" { } +module "statuscake-monitoring" { + depends_on = [ + module.cluster + ] + count = var.argo_enabled == true && var.statuscake_enabled == true ? 1 : 0 + source = "./modules/common/statuscake" + app_edge_url = "https://${local.dns_name}" + cluster_name = lower("${var.aws_account}-${var.region}-${var.label}") +} + resource "helm_release" "ipa-vso" { count = var.thanos_enabled == true ? 1 : 0 depends_on = [ diff --git a/main.tf b/main.tf index 576567b7..f91f181a 100644 --- a/main.tf +++ b/main.tf @@ -48,9 +48,17 @@ terraform { source = "loafoe/htpasswd" version = "1.0.4" } + statuscake = { + source = "StatusCakeDev/statuscake" + version = "2.2.2" + } } } +provider "statuscake" { + api_token = var.statuscake_api_key +} + provider "time" {} provider "keycloak" { @@ -183,11 +191,11 @@ module "private_networking" { } module "sqs_sns" { - count = var.sqs_sns == true ? 1 : 0 - source = "app.terraform.io/indico/indico-aws-sqs-sns/mod" - version = "1.2.0" - region = var.region - label = var.label + count = var.sqs_sns == true ? 1 : 0 + source = "app.terraform.io/indico/indico-aws-sqs-sns/mod" + version = "1.2.0" + region = var.region + label = var.label kms_master_key_id = module.kms_key.key.id } diff --git a/tf-smoketest-variables.tf b/tf-smoketest-variables.tf index d9a6b60a..f9aebe8a 100644 --- a/tf-smoketest-variables.tf +++ b/tf-smoketest-variables.tf @@ -139,6 +139,7 @@ resource "kubernetes_config_map" "terraform-variables" { on_prem_test = "${jsonencode(var.on_prem_test)}" harness_delegate = "${jsonencode(var.harness_delegate)}" harness_mount_path = "${jsonencode(var.harness_mount_path)}" + statuscake_enabled = "${jsonencode(var.statuscake_enabled)}" } } diff --git a/user_vars.auto.tfvars b/user_vars.auto.tfvars index 5b998d02..0b74337b 100644 --- a/user_vars.auto.tfvars +++ b/user_vars.auto.tfvars @@ -107,3 +107,5 @@ include_fsx = false include_efs = true #cluster az_count = 2 + +statuscake_enabled = true \ No newline at end of file diff --git a/variables.tf b/variables.tf index 9c524a06..dcc82de0 100644 --- a/variables.tf +++ b/variables.tf @@ -618,7 +618,7 @@ variable "enable_weather_station" { } variable "aws_primary_dns_role_arn" { - type = string + type = string default = "" description = "The AWS arn for the role needed to manage route53 DNS in a different account." } @@ -828,3 +828,16 @@ variable "harness_mount_path" { type = string default = "harness" } + +variable "statuscake_enabled" { + type = bool + default = false +} + +variable "statuscake_api_key" { + type = string + sensitive = true + default = "" +} + + From dffde75cc4818baac253ed4425576bbdac7670c1 Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Tue, 13 Feb 2024 11:01:54 -0500 Subject: [PATCH 2/5] Added missing folder --- modules/common/statuscake/providers.tf | 8 ++++++ modules/common/statuscake/statuscake.tf | 37 +++++++++++++++++++++++++ modules/common/statuscake/variables.tf | 16 +++++++++++ 3 files changed, 61 insertions(+) create mode 100644 modules/common/statuscake/providers.tf create mode 100644 modules/common/statuscake/statuscake.tf create mode 100644 modules/common/statuscake/variables.tf diff --git a/modules/common/statuscake/providers.tf b/modules/common/statuscake/providers.tf new file mode 100644 index 00000000..87e2775a --- /dev/null +++ b/modules/common/statuscake/providers.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + statuscake = { + source = "StatusCakeDev/statuscake" + version = "2.2.2" + } + } +} diff --git a/modules/common/statuscake/statuscake.tf b/modules/common/statuscake/statuscake.tf new file mode 100644 index 00000000..387ae648 --- /dev/null +++ b/modules/common/statuscake/statuscake.tf @@ -0,0 +1,37 @@ +resource "statuscake_uptime_check" "app-edge" { + check_interval = 60 + confirmation = 3 + name = var.cluster_name + trigger_rate = 10 + + contact_groups = [ + var.statuscake_devops_sa_contact_group_id + ] + + + http_check { + enable_cookies = true + follow_redirects = true + timeout = 20 + user_agent = "terraform managed uptime check" + validate_ssl = true + + status_codes = [ + "204", "205", "206", "303", "400", "401", "403", "404", + "405", "406", "408", "410", "413", "444", "429", "494", + "495", "497", "499", "500", "501", "502", "503", "504", + "505", "506", "507", "508", "509", "510", "511", "521", + "522", "523", "524", "520", "598", "599" + ] + } + + + + monitored_resource { + address = var.app_edge_url + } + + tags = [ + "tf_cod" + ] +} diff --git a/modules/common/statuscake/variables.tf b/modules/common/statuscake/variables.tf new file mode 100644 index 00000000..436e9574 --- /dev/null +++ b/modules/common/statuscake/variables.tf @@ -0,0 +1,16 @@ +variable "statuscake_contact_group_name" { + type = string + default = "devops-sa" +} + +variable "statuscake_devops_sa_contact_group_id" { + default = "307898" # group for devops-sa +} + +variable "cluster_name" { + type = string +} + +variable "app_edge_url" { + type = string +} From a104687866ac9a9216d4f8e4f7447fbca54c8485 Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Tue, 13 Feb 2024 12:14:59 -0500 Subject: [PATCH 3/5] Added ssl check --- modules/common/statuscake/statuscake.tf | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/common/statuscake/statuscake.tf b/modules/common/statuscake/statuscake.tf index 387ae648..49cc05cb 100644 --- a/modules/common/statuscake/statuscake.tf +++ b/modules/common/statuscake/statuscake.tf @@ -1,3 +1,25 @@ +resource "statuscake_ssl_check" "app-edge" { + check_interval = 43200 # every 12 hours + user_agent = "terraform managed SSL check" + follow_redirects = true + + alert_config { + alert_at = [29, 7, 1] + on_broken = false + on_expiry = true + on_mixed = false + on_reminder = true + } + + contact_groups = [ + var.statuscake_devops_sa_contact_group_id + ] + + monitored_resource { + address = var.app_edge_url + } +} + resource "statuscake_uptime_check" "app-edge" { check_interval = 60 confirmation = 3 From c852fe535066f067ea026977ae43536e1402c01a Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Tue, 13 Feb 2024 14:26:30 -0500 Subject: [PATCH 4/5] Added ssl check --- modules/common/statuscake/statuscake.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/common/statuscake/statuscake.tf b/modules/common/statuscake/statuscake.tf index 49cc05cb..666436c6 100644 --- a/modules/common/statuscake/statuscake.tf +++ b/modules/common/statuscake/statuscake.tf @@ -1,5 +1,5 @@ resource "statuscake_ssl_check" "app-edge" { - check_interval = 43200 # every 12 hours + check_interval = 3600 # every 6 hours user_agent = "terraform managed SSL check" follow_redirects = true From 30205876ae9478bd295fdd1b1516f4bd2d4a460c Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Thu, 21 Mar 2024 09:36:23 -0400 Subject: [PATCH 5/5] Set vars based upon name --- azure/user_vars.auto.tfvars | 2 +- user_vars.auto.tfvars | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/azure/user_vars.auto.tfvars b/azure/user_vars.auto.tfvars index c234cc37..9f5c1737 100644 --- a/azure/user_vars.auto.tfvars +++ b/azure/user_vars.auto.tfvars @@ -140,4 +140,4 @@ additional_node_pools = { } } -statuscake_enabled = true +statuscake_enabled = strcontains(lower(var.account), "indico-") ? true : false diff --git a/user_vars.auto.tfvars b/user_vars.auto.tfvars index 0b74337b..ff8024fa 100644 --- a/user_vars.auto.tfvars +++ b/user_vars.auto.tfvars @@ -108,4 +108,7 @@ include_efs = true #cluster az_count = 2 -statuscake_enabled = true \ No newline at end of file +statuscake_enabled = strcontains(lower(var.aws_account), "indico-") ? true : false + + +