importing all secrets
This commit is contained in:
@@ -35,6 +35,7 @@ resource "kubernetes_service_v1" "automatic_service" {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
depends_on = [resource.kubernetes_namespace_v1.automatic]
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,14 @@ variable "kubernetes" {
|
|||||||
service_account_name = optional(string)
|
service_account_name = optional(string)
|
||||||
environment_variables = optional(map(string), { name = "value" })
|
environment_variables = optional(map(string), { name = "value" })
|
||||||
security_context = optional(bool, false)
|
security_context = optional(bool, false)
|
||||||
|
import_database_secret = optional(object({
|
||||||
|
#putting them a non optional as the code doesn't allow optional value
|
||||||
|
host = string
|
||||||
|
name = string
|
||||||
|
password = string
|
||||||
|
port = string
|
||||||
|
username = string
|
||||||
|
}))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+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 {
|
import {
|
||||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_host["django-testing"]
|
for_each = local.database_secrets_to_import
|
||||||
id = "097f10de-63ee-405c-b46a-b41001781e07"
|
|
||||||
|
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 {
|
import {
|
||||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_name["django-testing"]
|
for_each = local.database_secrets_to_import
|
||||||
id = "20530a85-e446-4d79-8985-b41001781e07"
|
|
||||||
|
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_password[each.key]
|
||||||
|
id = each.value.import_database_secret.password
|
||||||
}
|
}
|
||||||
import {
|
import {
|
||||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_password["django-testing"]
|
for_each = local.database_secrets_to_import
|
||||||
id = "a3385f49-ba92-4478-b6f1-b4e100ff01fb"
|
|
||||||
|
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_port[each.key]
|
||||||
|
id = each.value.import_database_secret.port
|
||||||
}
|
}
|
||||||
import {
|
import {
|
||||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_port["django-testing"]
|
for_each = local.database_secrets_to_import
|
||||||
id = "e15e00eb-db1e-47ea-ab0e-b41001781e09"
|
|
||||||
}
|
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_username[each.key]
|
||||||
import {
|
id = each.value.import_database_secret.username
|
||||||
to = bitwarden-secrets_secret.automatic_bitwarden_secret_db_username["django-testing"]
|
|
||||||
id = "3c67d310-7113-45b7-8f3f-b41001781e08"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ kubernetes = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
django-testing = {
|
django-testing = {
|
||||||
enabled = false
|
#enabled = false
|
||||||
image = "gitea.tryton.geeraert.eu/pi-ux-ce/django-testing:latest"
|
image = "gitea.tryton.geeraert.eu/pi-ux-ce/django-testing:latest"
|
||||||
service_port = [8000]
|
service_port = [8000]
|
||||||
database = {}
|
database = {}
|
||||||
@@ -184,7 +184,7 @@ kubernetes = {
|
|||||||
requests-cpu = "10m"
|
requests-cpu = "10m"
|
||||||
requests-memory = "300Mi"
|
requests-memory = "300Mi"
|
||||||
}
|
}
|
||||||
extra_manifest = ["/opt/kubernetes/Terraform_kube/external_manifests/django/kubeconfig-testing.secret.yaml"]
|
extra_manifest = ["../external_manifests/django/kubeconfig-testing.secret.yaml"]
|
||||||
secret_ref = ["django-bitwarden-credentials"]
|
secret_ref = ["django-bitwarden-credentials"]
|
||||||
secret_import = ["68dce7aa-8e5f-4483-9083-b474016e34fc"]
|
secret_import = ["68dce7aa-8e5f-4483-9083-b474016e34fc"]
|
||||||
environment = {
|
environment = {
|
||||||
@@ -212,6 +212,15 @@ kubernetes = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import_database_secret = {
|
||||||
|
host = "097f10de-63ee-405c-b46a-b41001781e07"
|
||||||
|
name = "20530a85-e446-4d79-8985-b41001781e07"
|
||||||
|
password = "a3385f49-ba92-4478-b6f1-b4e100ff01fb"
|
||||||
|
port = "e15e00eb-db1e-47ea-ab0e-b41001781e09"
|
||||||
|
username = "3c67d310-7113-45b7-8f3f-b41001781e08"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user