Open johnlane opened 3 years ago
@johnlane hi, I believe this issue belongs upstream in the https://github.com/hashicorp/terraform repository since yamldecode
is a built-in function in Terraform (https://github.com/hashicorp/terraform/blob/a9487c76740ec8481bfe839f318341f716fd5388/website/docs/language/functions/yamldecode.html.md)
I think multi-document YAML support is almost essential. Most installation instructions I've come across (e.g. for CSI drivers, metrics-server, cluster autoscaler, etc) all involve multi-document YAML. I can certainly see why converting with tfk8s
makes sense, but that makes upgrading to the latest third-party manifests a bit more difficult.
I've come across https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/data-sources/kubectl_file_documents which offers multi-document YAML support, but I would also love to see it being officially supported.
I do realize it's easier said than done. One thing that would be interesting is keying the resulting sequence such that it could be used with for_each
You could split it and use for_each like this:
resource "kubernetes_manifest" "argo" {
provider = kubernetes-alpha
for_each = {
for i, v in split("\n---\n", file("multi.yaml")) : i => yamldecode(v)
}
manifest = each.value
}
Description
This is a follow-on to existing closed issue https://github.com/hashicorp/terraform-provider-kubernetes-alpha/issues/44.
Just as some feedback really, having tried using the provider to deploy MetalLB today. The install instructions provided by metallb apply two manifests using urls. One of these manifests is a multiple document yaml file.
Whilst it's possible to use the tfk8s tool to work around this issue, it would be good to (a) be able to use yaml directly and (b) allow that yaml to contain multiple documents.
Point (a) is already covered like this:
But the file can only contain one document. I know this limitation is mentioned on the blog post but, when working with upstream manifests, it would be good to be able to use them directly and not alter them in any way.
References
https://github.com/hashicorp/terraform-provider-kubernetes-alpha/issues/44.
Community Note