File tree Expand file tree Collapse file tree
infrastructure/modules/container-app-job Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,14 @@ resource "azurerm_container_app_job" "this" {
7171 }
7272 }
7373
74+ dynamic "secret" {
75+ for_each = var. secret_variables
76+ content {
77+ name = replace (lower (secret. key ), " _" , " -" )
78+ value = secret. value
79+ }
80+ }
81+
7482 # Define the container template for the job.
7583 template {
7684
@@ -92,6 +100,7 @@ resource "azurerm_container_app_job" "this" {
92100 value = env. value
93101 }
94102 }
103+
95104 dynamic "env" {
96105 for_each = var. fetch_secrets_from_app_key_vault ? data. azurerm_key_vault_secrets . app [0 ]. secrets : []
97106 content {
@@ -102,6 +111,16 @@ resource "azurerm_container_app_job" "this" {
102111 secret_name = lower (env. value . name )
103112 }
104113 }
114+
115+ dynamic "env" {
116+ for_each = var. secret_variables
117+ content {
118+ # Env vars are uppercase and underscore separated
119+ name = upper (replace (env. key , " -" , " _" ))
120+ # app container secrets are lowercase and hyphen separated
121+ secret_name = replace (lower (env. key ), " _" , " -" )
122+ }
123+ }
105124 }
106125 }
107126
Original file line number Diff line number Diff line change @@ -76,6 +76,12 @@ variable "environment_variables" {
7676 default = {}
7777}
7878
79+ variable "secret_variables" {
80+ description = " Secret environment variables to pass to the container app."
81+ type = map (string )
82+ default = {}
83+ }
84+
7985variable "job_parallelism" {
8086 description = " The number of replicas that can run in parallel."
8187 type = number
You can’t perform that action at this time.
0 commit comments