resource "kubernetes_manifest" "cluster-tls" {
  depends_on = [var.wait_on]

  manifest = {
    apiVersion = "cert-manager.io/v1"
    kind       = "Certificate"
    metadata = {
      name      = "${var.name}-tls"
      namespace = var.namespace
    }

    spec = {
      secretName = "${var.name}-tls"
      issuerRef = {
        name = "letsencrypt"
        kind = "ClusterIssuer"
      }
      dnsNames = var.hosts
    }
  }
}

output "installed" {
  value = true
  depends_on = [kubernetes_manifest.cluster-tls]
}
