Skip to content

Commit

Permalink
Revert template_filetemplate_file
Browse files Browse the repository at this point in the history
As template_file is cannot apply multiple manitest, instead use fileset

gavinbunney/terraform-provider-kubectl#141 (comment)
  • Loading branch information
vijay-veeranki committed Oct 7, 2022
1 parent 014ac7e commit 2e337cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
13 changes: 4 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ 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:
runAsUser: 999
serviceAccountName: namespace-check-sa

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand All @@ -32,6 +33,7 @@ subjects:
namespace: kuberhealthy

---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand All @@ -47,6 +49,7 @@ rules:
- watch

---

apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down

0 comments on commit 2e337cf

Please sign in to comment.