feat: update template

This commit is contained in:
2026-08-07 17:54:23 +02:00
parent 7da871de26
commit a29b90217e
2 changed files with 34 additions and 9 deletions
+25 -7
View File
@@ -33,9 +33,26 @@ locals {
ip_only = split("/", var.ip_address)[0] ip_only = split("/", var.ip_address)[0]
monitor_dnu_dns = var.monitor_dnu_dns != null ? var.monitor_dnu_dns : (local.is_prod ? true : false) 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" { module "vm" {
source = "git::https://git.itlab-ffeks.dnu.edu.ua/infrastructure/proxmox-vm.git" source = "git::https://git.itlab-ffeks.dnu.edu.ua/infrastructure/proxmox-vm.git"
@@ -51,13 +68,10 @@ module "vm" {
bridge = var.bridge bridge = var.bridge
} }
# 2. Internal DNS Record Creation
module "dns_record" { module "dns_record" {
source = "git::https://git.itlab-ffeks.dnu.edu.ua/infrastructure/dns-record.git" source = "git::https://git.itlab-ffeks.dnu.edu.ua/infrastructure/dns-record.git"
subdomain = var.subdomain subdomain = var.subdomain
} }
# 3. Uptime Kuma: Internal DNS Monitor
resource "uptimekuma_monitor_dns" "internal_dns" { resource "uptimekuma_monitor_dns" "internal_dns" {
name = "${var.service_name} Internal DNS Monitoring (${var.environment})" name = "${var.service_name} Internal DNS Monitoring (${var.environment})"
hostname = "${var.subdomain}.itlab-ffeks.dnu.edu.ua" 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" { resource "uptimekuma_monitor_dns" "dnu_dns" {
count = local.monitor_dnu_dns ? 1 : 0 count = local.monitor_dnu_dns ? 1 : 0
name = "${var.service_name} DNU DNS Monitoring (${var.environment})" 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" { resource "uptimekuma_monitor_ping" "ping" {
name = "Ping ${var.service_name} (${var.environment})" name = "Ping ${var.service_name} (${var.environment})"
hostname = local.ip_only hostname = local.ip_only
@@ -100,18 +112,24 @@ resource "uptimekuma_monitor_ping" "ping" {
tags = [ tags = [
{ {
tag_id = local.env_tag_id 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" { resource "uptimekuma_monitor_http" "http" {
name = "${var.service_name} HTTP Monitoring (${var.environment})" name = "${var.service_name} HTTP Monitoring (${var.environment})"
url = "http://${local.ip_only}${var.http_health_check_path}" url = "http://${local.ip_only}${var.http_health_check_path}"
parent = local.service_parent_group_id
tags = [ tags = [
{ {
tag_id = local.env_tag_id tag_id = local.env_tag_id
},
{
tag_id = local.service_type_tag_id
} }
] ]
} }
+7
View File
@@ -8,6 +8,13 @@ variable "service_name" {
type = string type = string
} }
variable "service_type" {
description = "The type of the service (e.g., internal_service, dataholder, module)"
type = string
default = "internal_service"
}
variable "subdomain" { variable "subdomain" {
description = "The subdomain prefix for the environment" description = "The subdomain prefix for the environment"
type = string type = string