resource "cloudns_dns_record" "alexpires_me_contabo" {
  name  = local.contabo_instance.name
  zone  = local.alexpires_me_zone
  type  = "A"
  value = local.contabo_instance.ip
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_code" {
  name  = "code"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_cloud" {
  name  = "cloud"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_tv" {
  name  = "tv"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_blog" {
  name  = "blog"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_www" {
  name  = "www"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_rustdesk" {
  name  = "rustdesk"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_prod_01" {
  name  = "prod-01"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_imaps" {
  name  = "imap"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_smtps" {
  name  = "smtp"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "${cloudns_dns_record.alexpires_me_contabo.name}.${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_root" {
  name  = ""
  zone  = local.alexpires_me_zone
  type  = "A"
  value = local.contabo_instance.ip
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_spf" {
  name  = ""
  zone  = local.alexpires_me_zone
  type  = "TXT"
  value = "v=spf1 include:_spf.tem.scaleway.com include:spf.webapps.net ~all"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_dkim" {
  name  = "${var.scaleway_dkim_key}._domainkey"
  zone  = local.alexpires_me_zone
  type  = "TXT"
  value = "v=DKIM1; h=sha256; k=rsa; p=${var.alexpires_me_scaleway_dkim_value}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_dmarc" {
  name  = "_dmarc"
  zone  = local.alexpires_me_zone
  type  = "TXT"
  value = "v=DMARC1; p=none; rua=mailto:admin@${local.alexpires_me_zone}"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_mx" {
  name     = ""
  zone     = local.alexpires_me_zone
  type     = "MX"
  priority = "10"
  value    = "mail-pt.securemail.pro"
  ttl      = "3600"
}

resource "cloudns_dns_record" "alexpires_me_mail" {
  name  = "mail"
  zone  = local.alexpires_me_zone
  type  = "CNAME"
  value = "mail-pt.securemail.pro"
  ttl   = "3600"
}

resource "cloudns_dns_record" "alexpires_me_mail_smtp_srv" {
  name     = "_smtp._tcp"
  zone     = local.alexpires_me_zone
  type     = "SRV"
  priority = 0
  weight   = 1
  port     = 465
  value    = "smtp.${local.alexpires_me_zone}"
  ttl      = "3600"
}

resource "cloudns_dns_record" "alexpires_me_mail_imap_srv" {
  name     = "_imap._tcp"
  zone     = local.alexpires_me_zone
  type     = "SRV"
  priority = 0
  weight   = 1
  port     = 993
  value    = "imap.${local.alexpires_me_zone}"
  ttl      = "3600"
}

resource "cloudns_dns_zone" "alexpires_me" {
  domain = local.alexpires_me_zone
  type   = "master"
}
import {
  to = cloudns_dns_zone.alexpires_me
  id = local.alexpires_me_zone
}

moved {
  from = cloudns_dns_record.alexpires_me_microk8s
  to   = cloudns_dns_record.alexpires_me_contabo
}
