# Cloudflare DNS Records for Proxmox Instances
# Domain: sankofa.nexus

# Get zone ID for sankofa.nexus
data "cloudflare_zones" "sankofa_nexus" {
  filter {
    name = "sankofa.nexus"
  }
}

locals {
  zone_id = data.cloudflare_zones.sankofa_nexus.zones[0].id
}

# Instance 1 (ML110-01) DNS Records
resource "cloudflare_record" "ml110_01" {
  zone_id = local.zone_id
  name    = "ml110-01"
  value   = "192.168.11.10"
  type    = "A"
  ttl     = 300
  comment = "Proxmox Instance 1 - ML110-01"
}

resource "cloudflare_record" "ml110_01_api" {
  zone_id = local.zone_id
  name    = "ml110-01-api"
  value   = "ml110-01.sankofa.nexus"
  type    = "CNAME"
  ttl     = 300
  comment = "Proxmox Instance 1 API endpoint"
}

resource "cloudflare_record" "ml110_01_metrics" {
  zone_id = local.zone_id
  name    = "ml110-01-metrics"
  value   = "ml110-01.sankofa.nexus"
  type    = "CNAME"
  ttl     = 300
  comment = "Proxmox Instance 1 metrics endpoint"
}

# Instance 2 (R630-01) DNS Records
resource "cloudflare_record" "r630_01" {
  zone_id = local.zone_id
  name    = "r630-01"
  value   = "192.168.11.11"
  type    = "A"
  ttl     = 300
  comment = "Proxmox Instance 2 - R630-01"
}

resource "cloudflare_record" "r630_01_api" {
  zone_id = local.zone_id
  name    = "r630-01-api"
  value   = "r630-01.sankofa.nexus"
  type    = "CNAME"
  ttl     = 300
  comment = "Proxmox Instance 2 API endpoint"
}

resource "cloudflare_record" "r630_01_metrics" {
  zone_id = local.zone_id
  name    = "r630-01-metrics"
  value   = "r630-01.sankofa.nexus"
  type    = "CNAME"
  ttl     = 300
  comment = "Proxmox Instance 2 metrics endpoint"
}

# Output DNS record IDs
output "dns_record_ids" {
  value = {
    ml110_01         = cloudflare_record.ml110_01.id
    ml110_01_api     = cloudflare_record.ml110_01_api.id
    ml110_01_metrics = cloudflare_record.ml110_01_metrics.id
    r630_01          = cloudflare_record.r630_01.id
    r630_01_api      = cloudflare_record.r630_01_api.id
    r630_01_metrics  = cloudflare_record.r630_01_metrics.id
  }
}

