Files
a13labs.infra/terraform/modules/apps/mail/stunnel.tf
T

57 lines
1.6 KiB
Terraform
Raw Normal View History

# This file defines the configuration for stunnel in the mail module.
# Creates a Kubernetes ConfigMap for stunnel configuration for Dovecot.
resource "kubernetes_config_map" "stunnel_dovecot" {
metadata {
name = "stunnel-dovecot"
namespace = kubernetes_namespace.mail.metadata[0].name
}
data = {
"stunnel.conf" = local.dovecot_stunnel_config
}
}
# Creates a Kubernetes ConfigMap for stunnel configuration for Postfix.
resource "kubernetes_config_map" "stunnel_postfix" {
metadata {
name = "stunnel-postfix"
namespace = kubernetes_namespace.mail.metadata[0].name
}
data = {
"stunnel.conf" = local.postfix_stunnel_config
}
}
# Creates a Kubernetes manifest for the stunnel certificate using cert-manager.
resource "kubernetes_manifest" "stunnel_cert" {
manifest = {
apiVersion = "cert-manager.io/v1"
kind = "Certificate"
metadata = {
name = "stunnel-cert"
namespace = kubernetes_namespace.mail.metadata[0].name
}
spec = {
secretName = "stunnel-cert"
issuerRef = {
name = var.issuer
kind = "ClusterIssuer"
}
commonName = "${kubernetes_service.dovecot_auth.metadata[0].name}.${kubernetes_namespace.mail.metadata[0].name}.svc.cluster.local"
dnsNames = ["${kubernetes_service.dovecot_auth.metadata[0].name}.${kubernetes_namespace.mail.metadata[0].name}.svc.cluster.local"]
}
}
}
# Creates a Kubernetes ConfigMap for the CA certificate.
resource "kubernetes_config_map" "ca_pem" {
metadata {
name = "ca-pem"
namespace = kubernetes_namespace.mail.metadata[0].name
}
data = {
"ca.pem" = var.ca_pem
}
}