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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user