Skip to content

Commit

Permalink
Replace kubectl_path_documents with template_file
Browse files Browse the repository at this point in the history
This is fix error: Invalid count argument
Caused by issue:
gavinbunney/terraform-provider-kubectl#61
  • Loading branch information
vijay-veeranki committed Oct 7, 2022
1 parent 548dac3 commit cd96fa4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ resource "helm_release" "kuberhealthy" {
# kuberhealthy placeholder for our future custom alerts#
#########################

data "kubectl_path_documents" "namespace_check_manifests" {
pattern = "${path.module}/resources/namespace-check.yaml"
data "template_file" "namespace_check_manifests" {

template = file(
"${path.module}/resources/namespace-check.yaml.tpl",
)

vars = {
namespace_check_version = "1.1"
}
}

resource "kubectl_manifest" "namespacecheck_rule_alert" {
count = length(data.kubectl_path_documents.namespace_check_manifests.documents)
yaml_body = element(data.kubectl_path_documents.namespace_check_manifests.documents, count.index)
yaml_body = data.template_file.namespace_check_manifests.rendered
depends_on = [helm_release.kuberhealthy]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:1.1
image: ministryofjustice/cloud-platform-kuberhealthy-namespace-check:${namespace_check_version}
imagePullPolicy: IfNotPresent
name: main
securityContext:
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
helm = {
source = "hashicorp/helm"
source = "hashicorp/helm"
version = "~> 2.6.0"
}
kubernetes = {
Expand Down

0 comments on commit cd96fa4

Please sign in to comment.