filter to not create the pvc if different than pointing to a pvc

This commit is contained in:
2024-12-11 22:15:01 +00:00
parent a15d0e8148
commit 87237f6b68
+3 -2
View File
@@ -13,7 +13,7 @@ variable "kubernetes" {
image = string image = string
pvc = optional(map(object({ pvc = optional(map(object({
name = string name = string
pvc = optional(bool,false) pvc = optional(bool, false)
config_map = optional(bool, false) config_map = optional(bool, false)
host_path = optional(string) host_path = optional(string)
pvc_size = optional(string) pvc_size = optional(string)
@@ -59,6 +59,7 @@ locals {
for key, value in var.kubernetes : [ for key, value in var.kubernetes : [
for index, pvc in value.pvc : { for index, pvc in value.pvc : {
index = index index = index
pvc = pvc.pvc
name = pvc.name name = pvc.name
pvc_size = pvc.pvc_size pvc_size = pvc.pvc_size
mount_path = pvc.mount_path mount_path = pvc.mount_path
@@ -129,7 +130,7 @@ resource "kubernetes_namespace" "automatic" {
#} #}
resource "kubernetes_persistent_volume_claim" "automatic-pvc" { resource "kubernetes_persistent_volume_claim" "automatic-pvc" {
for_each = { for key, value in local.pvc_details : "${value.index}" => merge(value, { mew_key = value.index }) } for_each = { for key, value in local.pvc_details : "${value.index}" => merge(value, { mew_key = value.index }) if value.pvc }
metadata { metadata {
namespace = each.value.namespace namespace = each.value.namespace
name = "${each.value.name}-pvc" name = "${each.value.name}-pvc"