In your try() block, when the attribute doesn't exist, it correctly returns . However, when the attribute does exist, it returns the whole nested object (e.g., { host = ..., name = ... }). In Terraform, comparing a complex object/map to an empty string ({...} != ) is technically invalid or doesn't evaluate cleanly to a false check, causing the filter to let it slip through or crash when it expects a string.

This commit is contained in:
pi-ux-ce@ARES
2026-10-13 18:47:57 +01:00
parent aef087cfe1
commit c9ade2f851
2 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_name" {
locals {
database_secrets_to_import = {
for key, value in var.kubernetes : key => value
if value.database != null && value.enabled == true && try(value.import_database_secret, "") != ""
if value.database != null && value.enabled == true && can(value.import_database_secret.host)
}
}
+1 -1
View File
@@ -69,7 +69,7 @@ kubernetes = {
mountPath = "/var/lib/postgresql/data"
}
secret_ref = ["django-bitwarden-credentials"]
secret_import = ["9fc5a725-75f5-4bab-b595-b474017146c3"]
#secret_import = ["9fc5a725-75f5-4bab-b595-b474017146c3"]
requirements = {
limits-cpu = "800m"
limits-memory = "800Mi"