module "vigil_nginx_config" {
  # tflint-ignore: terraform_module_pinned_source
  source   = "git::https://code.techinc.nl/grey/terraform-nginx.git//nginx-site-available"
  hostname = "vigil.california.ti"
  //certificate   = acme_certificate.ooo_grey["s3"]
  service_name  = "vigil"
  upstream_host = "${module.vigil.docker_service_name}:8080"
  config_prefix = "nginx"
  allow_non_ssl = true
  allow_ssl     = false
}
variable "telegram_token" {
  type    = string
  default = ""
}
variable "telegram_channel" {
  type    = string
  default = ""
}
variable "telegram_topic" {
  type    = string
  default = ""
}
module "vigil" {
  source = "./modules/vigil"
  monitored_services = {
    "Servers" = [
      {
        id    = "longhorn"
        label = "Longhorn (longhorn.ti)"
        endpoints = [
          #"icmp://longhorn.ti", # ??? why?
          "tcp://longhorn.ti:22",
          #"https://longhorn.ti:8006", # cannot be used as the SSL cert is self-signed/invalid
        ]
      },
      {
        id    = "bargur"
        label = "Bargur (bargur.ti)"
        endpoints = [
          "icmp://bargur.ti",
          "tcp://bargur.ti:22",
          #"https://bargur.ti:8006", # cannot be used as the SSL cert is self-signed/invalid
        ]
      },
      {
        id    = "hanwoo"
        label = "Hanwoo (hanwoo.ti)"
        endpoints = [
          "icmp://hanwoo.ti",
          "tcp://hanwoo.ti:22",
          #"https://hanwoo.ti:8006" # cannot be used as the SSL cert is self-signed/invalid
        ]
      },
      {
        id    = "california"
        label = "California (california.ti)"
        endpoints = [
          "icmp://california.ti",
          "tcp://california.ti:22",
        ]
      },
      {
        id    = "backup"
        label = "Backup Server"
        endpoints = [
          #"icmp://backup.ti", # ??? Doesn't work?
          "tcp://backup.ti:22",
          "http://backup.ti",
        ]
      },
    ]
    "PDUs" = [
      {
        id    = "pdu-main"
        label = "PDU Main Space"
        endpoints = [
          "icmp://main.pdu.ti",
          "tcp://main.pdu.ti:23",
        ]
        }, {
        id    = "pdu-aux"
        label = "PDU Aux Space"
        endpoints = [
          "icmp://aux.pdu.ti",
          "tcp://aux.pdu.ti:23",
        ]
        }, {
        id    = "pdu-printers"
        label = "PDU Printers"
        endpoints = [
          "icmp://printer.pdu.ti",
          "tcp://printer.pdu.ti:23",
        ]
      }
    ]
    "Wifi" = [
      {
        id    = "unifi-controller"
        label = "Unifi Controller"
        endpoints = [
          "icmp://unifi.ti",
          "tcp://unifi.ti:22",
          "http://unifi.ti",
        ]
      },
      {
        id    = "unifi-ap-mainspace"
        label = "Unifi AP Mainspace"
        endpoints = [
          # "icmp://mainspace-ap.ti", # Painfully, ICMP said it was up when it was infact entirely unplugged. No ICMP for you.
          "tcp://mainspace-ap.ti:22",
        ]
      },
      {
        id    = "unifi-ap-auxspace"
        label = "Unifi AP Auxspace"
        endpoints = [
          # "icmp://auxspace-ap.ti", # Painfully, ICMP said it was up when it was infact entirely unplugged. No ICMP for you.
          "tcp://auxspace-ap.ti:22",
        ]
      },
      {
        id    = "unifi-ap-toilets"
        label = "Unifi AP Hallway/Toilets"
        endpoints = [
          "icmp://toilet-ap.ti",
        ]
      },
    ]
    "Printers" = [
      {
        id    = "prin.ti"
        label = "Prin.ti (Print Controller)"
        endpoints = [
          "icmp://prin.ti",
          "tcp://prin.ti:22",
        ]
        }, {
        id    = "ender5plus"
        label = "Ender 5 Plus"
        endpoints = [
          "http://prin.ti:3000",
        ]
        }, {
        id    = "v400"
        label = "FLSun V400"
        endpoints = [
          "icmp://v400.prin.ti",
          "tcp://v400.prin.ti:22",
          "http://v400.prin.ti",
        ]
      }
    ],
    "Space Services" = [
      {
        id    = "sso"
        label = "SSO (auth.techinc.nl)"
        endpoints = [
          "icmp://auth.techinc.nl",
          "https://auth.techinc.nl"
        ]
        }, {
        id    = "forgejo"
        label = "TechInc Git Server"
        endpoints = [
          "https://code.techinc.nl/api/v1/version"
        ]
        http_method = "GET"
        }, {
        id    = "ansible"
        label = "TechInc Ansible Server"
        endpoints = [
          #"icmp://ansible.ti", # Doesn't work?
          "tcp://ansible.ti:22",
          #"http://ansible.ti", # Doesn't work?
        ]
        http_method = "GET"
      },
      {
        id    = "jukebox"
        label = "Indicio (Jukebox)"
        endpoints = [
          "icmp://indicio.ti",
          "tcp://indicio.ti:22",
        ]
        http_method = "GET"
      },
      {
        id    = "shardik"
        label = "Shardik (Bot)"
        endpoints = [
          #"icmp://shardik.ti", # Doesn't work?
          "tcp://shardik.ti:22",
          "http://shardik.ti",
        ]
        http_method = "GET"
      },
      {
        id    = "sip"
        label = "SIP"
        endpoints = [
          #"icmp://sip.ti", # Doesn't work?
          "http://sip.ti",
        ]
        http_method = "GET"
      },
      {
        id    = "wheel"
        label = "TI Wheel"
        endpoints = [
          "icmp://wheel.ti",
          #"http://wheel.ti" # requires basic auth
        ]
        http_method = "GET"
      },
      {
        id    = "arrow"
        label = "TI Arrow"
        endpoints = [
          "icmp://arrow.ti",
          #"http://arrow.ti" # requires basic auth
        ]
        http_method = "GET"
      }
    ],
    "Members Services" = [
      {
        id    = "s3"
        label = "S3 (s3.california.ti)"
        endpoints = [
          "icmp://s3.california.ti",
          "http://s3.california.ti/minio/health/live",
          "http://s3.california.ti/ui"
        ]
      }
    ]
  }
  docker_networks = [
    docker_network.loadbalancer
  ]
  notify_on_startup = true
  notify_telegram = {
    token   = var.telegram_token
    channel = var.telegram_channel
    topic   = var.telegram_topic
  }
}