From 50614e3dbd6e002992f68b2328b72d37f5b89ab1 Mon Sep 17 00:00:00 2001 From: Garland Kan Date: Wed, 23 Mar 2022 18:46:09 -0700 Subject: [PATCH] Manifest set (#276) --- .../aws/kubernetes/manifest_set/main.tf | 4 ++-- .../aws/kubernetes/manifest_set/variables.tf | 15 +++++++++++++++ .../base-tests/test-suites/infra-base/main.tf | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/terraform-modules/aws/kubernetes/manifest_set/main.tf b/terraform-modules/aws/kubernetes/manifest_set/main.tf index a00a294b7..654fc5f13 100644 --- a/terraform-modules/aws/kubernetes/manifest_set/main.tf +++ b/terraform-modules/aws/kubernetes/manifest_set/main.tf @@ -1,5 +1,5 @@ # Uploads all of the files in the pass in dir path and subdirectories resource "kubernetes_manifest" "this" { - for_each = fileset(var.upload_directory, "**/*.*") - manifest = yamldecode(file("${var.upload_source_path}/${var.upload_directory}/${each.value}")) + for_each = fileset(var.upload_directory, var.fileset_pattern) + manifest = yamldecode(templatefile("${var.upload_source_path}/${var.upload_directory}/${each.value}", var.template_vars)) } diff --git a/terraform-modules/aws/kubernetes/manifest_set/variables.tf b/terraform-modules/aws/kubernetes/manifest_set/variables.tf index 953d758c7..178af7cf3 100644 --- a/terraform-modules/aws/kubernetes/manifest_set/variables.tf +++ b/terraform-modules/aws/kubernetes/manifest_set/variables.tf @@ -4,8 +4,23 @@ variable "upload_directory" { description = "Just the directory name containing the folder to recursively apply from." } +variable "fileset_pattern" { + type = string + default = "**/*.*" + description = "The fileset() pattern match string. Useful if you have other files that are not yaml files that you dont want to add in to be applied to the kube manifest." +} + + variable "upload_source_path" { type = string default = "path.cwd" description = "The full path to where the directory var.upload_directory resides (not including the var.upload_directory dir name)." } + +variable "template_vars" { + type = map + default = {} + description = "The map for the templatefile() function to run the yamls through" +} + + diff --git a/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf index 082390ebf..fef78f42f 100644 --- a/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf +++ b/terraform-modules/aws/testkube/base-tests/test-suites/infra-base/main.tf @@ -1,5 +1,5 @@ module "manifest_set" { - source = "github.com/ManagedKube/kubernetes-ops.git//terraform-modules/aws/kubernetes/manifest_set?ref=v2.0.11" + source = "github.com/ManagedKube/kubernetes-ops.git//terraform-modules/aws/kubernetes/manifest_set?ref=v2.0.12" upload_source_path = path.cwd upload_directory = "yaml"