importing all secrets
This commit is contained in:
+33
-12
@@ -155,23 +155,44 @@ resource "bitwarden-secrets_secret" "automatic_bitwarden_secret_db_name" {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
# 1. Move the loop logic to a local variable first
|
||||
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, "") != ""
|
||||
}
|
||||
}
|
||||
|
||||
# 2. Reference the local map in your import block using each.key and each.value
|
||||
import {
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_host["django-testing"]
|
||||
id = "097f10de-63ee-405c-b46a-b41001781e07"
|
||||
for_each = local.database_secrets_to_import
|
||||
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_host[each.key]
|
||||
id = each.value.import_database_secret.host
|
||||
}
|
||||
|
||||
import {
|
||||
for_each = local.database_secrets_to_import
|
||||
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_name[each.key]
|
||||
id = each.value.import_database_secret.name
|
||||
}
|
||||
import {
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_name["django-testing"]
|
||||
id = "20530a85-e446-4d79-8985-b41001781e07"
|
||||
for_each = local.database_secrets_to_import
|
||||
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_password[each.key]
|
||||
id = each.value.import_database_secret.password
|
||||
}
|
||||
import {
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_password["django-testing"]
|
||||
id = "a3385f49-ba92-4478-b6f1-b4e100ff01fb"
|
||||
for_each = local.database_secrets_to_import
|
||||
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_port[each.key]
|
||||
id = each.value.import_database_secret.port
|
||||
}
|
||||
import {
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_port["django-testing"]
|
||||
id = "e15e00eb-db1e-47ea-ab0e-b41001781e09"
|
||||
}
|
||||
import {
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_username["django-testing"]
|
||||
id = "3c67d310-7113-45b7-8f3f-b41001781e08"
|
||||
for_each = local.database_secrets_to_import
|
||||
|
||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_username[each.key]
|
||||
id = each.value.import_database_secret.username
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user