From 56902062f7651b553c37ef1dfa4ed21d27f1f898 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 14 May 2021 18:30:01 +0200 Subject: [PATCH] Terraform uptimerobot monitors Add our uptimerobot to terraform so it's managed in code and we can easily extend it. This currently only adds our to be monitored sites and leaves the status page as is now. Deleting resources on uptimerobot will cause terraform unable to run see: https://github.com/louy/terraform-provider-uptimerobot/issues/82 --- group_vars/all/vault_uptimerobot.yml | 11 +++++++ tf-stage2/.terraform.lock.hcl | 19 ++++++++++++ tf-stage2/uptimerobot.tf | 45 ++++++++++++++++++++++++++++ tf-stage2/versions.tf | 4 +++ 4 files changed, 79 insertions(+) create mode 100644 group_vars/all/vault_uptimerobot.yml create mode 100644 tf-stage2/uptimerobot.tf diff --git a/group_vars/all/vault_uptimerobot.yml b/group_vars/all/vault_uptimerobot.yml new file mode 100644 index 000000000..d9f12015d --- /dev/null +++ b/group_vars/all/vault_uptimerobot.yml @@ -0,0 +1,11 @@ +$ANSIBLE_VAULT;1.1;AES256 +62633262613331616434383361643166396632326534376238363661343162383563633738666165 +3265376465363330373030636337643838663232346331660a356536353363363837323466363066 +65363737363465643633323536393261636438383336343334656439333136383934376538653466 +3965373639366131330a633962366637396332363237363364383238663133323664616132303365 +62653761353366623364363365633937343339386562323133353030316635376265356166343965 +64333931383836306563373138383262313335663530623863666565656136653162333437333536 +34346632313438386362643433373936346266353562333562303562303432316330663261303636 +32363735346366323038346336386364313634356131633463373837366261623534626361636563 +36656164633363396231346135643765663062656230333838343538643361383632373533306236 +3261343064333737346166316562616637353330373736633634 diff --git a/tf-stage2/.terraform.lock.hcl b/tf-stage2/.terraform.lock.hcl index e13204fa2..276336bde 100644 --- a/tf-stage2/.terraform.lock.hcl +++ b/tf-stage2/.terraform.lock.hcl @@ -18,6 +18,25 @@ provider "registry.terraform.io/hashicorp/external" { ] } +provider "registry.terraform.io/louy/uptimerobot" { + version = "0.5.1" + constraints = "0.5.1" + hashes = [ + "h1:Oc5L04pt+5NJ8n47K7tVHbqFmuobW/x5zaF5sPGCQwE=", + "zh:0cab4092125cf524a2e5caf74a4e90f230734b20bbceb20e51ffb82f2fcc90fc", + "zh:130d9d9ddb2f9070d7846066d424d785a624472a25b413382bf6e80ad4754158", + "zh:29c1ff142ec76adb751cf1e99b2c7bd9ba5f17b97bfcce5954043db9c4a83039", + "zh:2ade3d4b911bcceb795b009105dfd58c40d27d06c2ea7402159a76559e86dd25", + "zh:474d83e659597ee143d09100787bb35daf05dc2a0b3fbfcb8159792143b8c598", + "zh:62694db2f947bafb00532a5b961067eb488005061e684eb74148bcbf80805270", + "zh:6a4e423519a331328764ba0790eb79c63882e77aa8ffdf811a319b5efaf7034e", + "zh:7e7f7c16f54690f84fcb6d1a90848bd51fc7b2eb2cc23bfa0583e18a80157393", + "zh:a4a63a32ac0bbe0d11fda36768c824698db4c2378cbfdf5522276fe996621864", + "zh:af3062664c5c4ec012af48dea769318dcb8ef77cbb59f15d8b6c252fb9adda85", + "zh:de555bac4bd86d17e7b5592ec22a6db8d1496470d3dab4fa286a86e44bdad991", + ] +} + provider "registry.terraform.io/mrparkers/keycloak" { version = "2.0.0" constraints = "2.0.0" diff --git a/tf-stage2/uptimerobot.tf b/tf-stage2/uptimerobot.tf new file mode 100644 index 000000000..d1f93e7a9 --- /dev/null +++ b/tf-stage2/uptimerobot.tf @@ -0,0 +1,45 @@ +data "external" "vault_uptimerobot" { + program = ["${path.module}/../misc/get_key.py", "group_vars/all/vault_uptimerobot.yml", + "vault_uptimerobot_api_key", + "vault_uptimerobot_alert_contact", + "--format", "json"] +} + +provider "uptimerobot" { + api_key = data.external.vault_uptimerobot.result.vault_uptimerobot_api_key +} + +data "uptimerobot_account" "account" {} + +data "uptimerobot_alert_contact" "default_alert_contact" { + friendly_name = data.external.vault_uptimerobot.result.vault_uptimerobot_alert_contact +} + +locals { + # This creates to be monitored websites. + # Every line consists of "key" = "value": + # - key equals the friendly name + # - value equals the website url + archlinux_org_monitor = { + "Wiki" = "https://wiki.archlinux.org" + "Website" = "https://archlinux.org" + "Security Tracker" = "https://security.archlinux.org" + "Gitlab" = "https://gitlab.archlinux.org" + "Forum" = "https://bbs.archlinux.org" + "Bugtracker" = "https://bugs.archlinux.org" + "AUR" = "https://aur.archlinux.org" + } +} + +resource "uptimerobot_monitor" "uptimerobot_monitor_archlinux" { + for_each = local.archlinux_org_monitor + + friendly_name = each.key + type = "http" + url = each.value + interval = 60 + + alert_contact { + id = data.uptimerobot_alert_contact.default_alert_contact.id + } +} diff --git a/tf-stage2/versions.tf b/tf-stage2/versions.tf index aa545e7b8..e21b91f54 100644 --- a/tf-stage2/versions.tf +++ b/tf-stage2/versions.tf @@ -7,6 +7,10 @@ terraform { source = "mrparkers/keycloak" version = "2.0.0" } + uptimerobot = { + source = "louy/uptimerobot" + version = "0.5.1" + } } required_version = ">= 0.13" }