Skip to content

Commit

Permalink
Merge pull request #9 from ministryofjustice/use-template
Browse files Browse the repository at this point in the history
Replace kubectl_path_documents with template_file
  • Loading branch information
vijay-veeranki authored Oct 7, 2022
2 parents 548dac3 + 7f04631 commit 014ac7e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module "kuberhealthy" {
| <a name="provider_helm"></a> [helm](#provider\_helm) | ~> 2.6.0 |
| <a name="provider_kubectl"></a> [kubectl](#provider\_kubectl) | n/a |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | n/a |
| <a name="provider_template"></a> [template](#provider\_template) | n/a |

## Modules

Expand All @@ -37,7 +38,7 @@ No modules.
| [helm_release.kuberhealthy](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [kubectl_manifest.namespacecheck_rule_alert](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/resources/manifest) | resource |
| [kubernetes_namespace.kuberhealthy](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
| [kubectl_path_documents.namespace_check_manifests](https://registry.terraform.io/providers/gavinbunney/kubectl/latest/docs/data-sources/path_documents) | data source |
| [template_file.namespace_check_manifests](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |

## Inputs

Expand Down
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 014ac7e

Please sign in to comment.