One solution is to generate the Kubernetes yaml from a template.
The pattern uses templatefile function in Terraform 0.12 or the template provider earlier versions to read and local_file resource to write. For example:
data "template_file""service_template" { template = "${file("${path.module}/templates/service.tpl")}" vars { postgres_password = ""${module.postgres.db_master_pass}" }}resource "local_file""template" { content = "${data.template_file.service_template.rendered}" filename = "postegres_service.yaml"}
There are many other options, like using to the Kubernetes provider, but I think this better matches your question.