I'm using the terraform kubernetes-provider and I'd like to translate something like this kubectl
command into TF:
kubectl create secret generic my-secret --from-file mysecret.json
It seems, however the secret
resource's data
field expects only a TF map.
I've tried something like
data "template_file" "my-secret" {
template = "${file("${path.module}/my-secret.json")}"
}
resource "kubernetes_secret" "sgw-config" {
metadata {
name = "my-secret"
}
type = "Opaque"
data = "{data.template_file.my-secret.template}"
}
But it complains that this is not a map. So, I can do something like this:
data = {
"my-secret.json" = "{data.template_file.my-secret.template}"
}
But this will write the secret with a top-level field named my-secret.json
and when I volume mount it, it won't work with other resources.
What is the trick here?