From a29b90217e0e647e35aab22685589e7f9896899b Mon Sep 17 00:00:00 2001 From: InAnYan Date: Fri, 7 Aug 2026 17:54:23 +0200 Subject: [PATCH] feat: update template --- main.tf | 36 +++++++++++++++++++++++++++--------- variables.tf | 7 +++++++ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/main.tf b/main.tf index da01375..3560ee0 100644 --- a/main.tf +++ b/main.tf @@ -33,9 +33,26 @@ locals { ip_only = split("/", var.ip_address)[0] monitor_dnu_dns = var.monitor_dnu_dns != null ? var.monitor_dnu_dns : (local.is_prod ? true : false) + + service_type_tag_id = ( + var.service_type == "dataholder" ? data.terraform_remote_state.uptime.outputs.tag_dataholder_id : + var.service_type == "module" ? data.terraform_remote_state.uptime.outputs.tag_module_id : + data.terraform_remote_state.uptime.outputs.tag_internal_service_id + ) + + service_parent_group_id = ( + local.is_prod ? ( + var.service_type == "dataholder" ? data.terraform_remote_state.uptime.outputs.monitor_group_prod_dataholders_id : + var.service_type == "module" ? data.terraform_remote_state.uptime.outputs.monitor_group_prod_modules_id : + data.terraform_remote_state.uptime.outputs.monitor_group_prod_internal_services_id + ) : ( + var.service_type == "dataholder" ? data.terraform_remote_state.uptime.outputs.monitor_group_staging_dataholders_id : + var.service_type == "module" ? data.terraform_remote_state.uptime.outputs.monitor_group_staging_modules_id : + data.terraform_remote_state.uptime.outputs.monitor_group_staging_internal_services_id + ) + ) } -# 1. Proxmox VM Creation module "vm" { source = "git::https://git.itlab-ffeks.dnu.edu.ua/infrastructure/proxmox-vm.git" @@ -51,13 +68,10 @@ module "vm" { bridge = var.bridge } -# 2. Internal DNS Record Creation module "dns_record" { source = "git::https://git.itlab-ffeks.dnu.edu.ua/infrastructure/dns-record.git" subdomain = var.subdomain } - -# 3. Uptime Kuma: Internal DNS Monitor resource "uptimekuma_monitor_dns" "internal_dns" { name = "${var.service_name} Internal DNS Monitoring (${var.environment})" hostname = "${var.subdomain}.itlab-ffeks.dnu.edu.ua" @@ -74,7 +88,6 @@ resource "uptimekuma_monitor_dns" "internal_dns" { ] } -# 4. Uptime Kuma: DNU DNS Monitor (Configurable, default true for prod, false for staging) resource "uptimekuma_monitor_dns" "dnu_dns" { count = local.monitor_dnu_dns ? 1 : 0 name = "${var.service_name} DNU DNS Monitoring (${var.environment})" @@ -91,7 +104,6 @@ resource "uptimekuma_monitor_dns" "dnu_dns" { ] } -# 5. Uptime Kuma: VM Ping Monitor resource "uptimekuma_monitor_ping" "ping" { name = "Ping ${var.service_name} (${var.environment})" hostname = local.ip_only @@ -100,18 +112,24 @@ resource "uptimekuma_monitor_ping" "ping" { tags = [ { tag_id = local.env_tag_id + }, + { + tag_id = local.service_type_tag_id } ] } -# 6. Uptime Kuma: HTTP health check Monitor (Configurable path, default "/") resource "uptimekuma_monitor_http" "http" { - name = "${var.service_name} HTTP Monitoring (${var.environment})" - url = "http://${local.ip_only}${var.http_health_check_path}" + name = "${var.service_name} HTTP Monitoring (${var.environment})" + url = "http://${local.ip_only}${var.http_health_check_path}" + parent = local.service_parent_group_id tags = [ { tag_id = local.env_tag_id + }, + { + tag_id = local.service_type_tag_id } ] } diff --git a/variables.tf b/variables.tf index 66154fd..745903c 100644 --- a/variables.tf +++ b/variables.tf @@ -8,6 +8,13 @@ variable "service_name" { type = string } +variable "service_type" { + description = "The type of the service (e.g., internal_service, dataholder, module)" + type = string + default = "internal_service" +} + + variable "subdomain" { description = "The subdomain prefix for the environment" type = string