From 2e337cfb41f6a687a2774a2473cc352e53e311a4 Mon Sep 17 00:00:00 2001 From: Vijay Veeranki Date: Fri, 7 Oct 2022 14:53:06 +0100 Subject: [PATCH] Revert template_filetemplate_file As template_file is cannot apply multiple manitest, instead use fileset https://github.com/gavinbunney/terraform-provider-kubectl/issues/141#issuecomment-1066774365 --- main.tf | 13 ++++--------- ...amespace-check.yaml.tpl => namespace-check.yaml} | 5 ++++- 2 files changed, 8 insertions(+), 10 deletions(-) rename resources/{namespace-check.yaml.tpl => namespace-check.yaml} (97%) diff --git a/main.tf b/main.tf index 295dff3..3f507e8 100644 --- a/main.tf +++ b/main.tf @@ -60,18 +60,13 @@ resource "helm_release" "kuberhealthy" { # kuberhealthy placeholder for our future custom alerts# ######################### -data "template_file" "namespace_check_manifests" { - template = file( - "${path.module}/resources/namespace-check.yaml.tpl", - ) - - vars = { - namespace_check_version = "1.1" - } +data "kubectl_path_documents" "namespace_check_manifests" { + pattern = "${path.module}/resources/namespace-check.yaml" } resource "kubectl_manifest" "namespacecheck_rule_alert" { - yaml_body = data.template_file.namespace_check_manifests.rendered + count = length(fileset(data.kubectl_path_documents.namespace_check_manifests.documents)) + yaml_body = element(data.kubectl_path_documents.namespace_check_manifests.documents, count.index) depends_on = [helm_release.kuberhealthy] } diff --git a/resources/namespace-check.yaml.tpl b/resources/namespace-check.yaml similarity index 97% rename from resources/namespace-check.yaml.tpl rename to resources/namespace-check.yaml index 9aafde0..fe4e710 100644 --- a/resources/namespace-check.yaml.tpl +++ b/resources/namespace-check.yaml @@ -10,7 +10,7 @@ spec: podSpec: # The exact pod spec that will run. All normal pod spec is valid here. containers: - env: [] # Environment variables are optional but a recommended way to configure check behavior - image: ministryofjustice/cloud-platform-kuberhealthy-namespace-check:${namespace_check_version} + image: ministryofjustice/cloud-platform-kuberhealthy-namespace-check:1.1 imagePullPolicy: IfNotPresent name: main securityContext: @@ -18,6 +18,7 @@ spec: serviceAccountName: namespace-check-sa --- + apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: @@ -32,6 +33,7 @@ subjects: namespace: kuberhealthy --- + apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -47,6 +49,7 @@ rules: - watch --- + apiVersion: v1 kind: ServiceAccount metadata: