Skip to content

Commit 8697040

Browse files
committed
convert secrets to dynamic block
1 parent 24705b9 commit 8697040

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

main.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ resource "kubernetes_deployment" "this" {
5050
}
5151
}
5252

53-
env_from {
54-
secret_ref {
55-
name = var.secret_name
56-
optional = true
53+
dynamic "env_from" {
54+
for_each = var.secrets
55+
56+
content {
57+
secret_ref {
58+
name = env_from.value
59+
}
5760
}
5861
}
5962
}

variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ variable "replicas" {
5252
default = 1
5353
}
5454

55-
variable "secret_name" {
56-
description = "https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/deployment#name"
57-
default = ""
55+
variable "secrets" {
56+
description = "List of secret names from which env_from blocks will be generated"
57+
default = []
5858
}
5959

6060
variable "config" {

0 commit comments

Comments
 (0)