variable "cert_path" {
description = "Path to the TLS certificate"
type = string
default = "certs/tls.crt"
}
variable "key_path" {
description = "Path to the TLS key"
type = string
default = "certs/tls.key"
}
computed "cert_b64" {
expression = filebase64(var.cert_path)
}
computed "key_b64" {
expression = filebase64(var.key_path)
}
task "create-tls-secret" {
description = "Create or update the TLS secret in Kubernetes"
commands = [
<<-EOT
kubectl create secret generic tls-secret \
--from-literal=tls.crt=${computed.cert_b64} \
--from-literal=tls.key=${computed.key_b64} \
--dry-run=client -o yaml | kubectl apply -f -
EOT
]
}