File tree Expand file tree Collapse file tree
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 {
@@ -100,6 +109,14 @@ resource "azurerm_container_app_job" "this" {
100109 # KV secrets are uppercase and hyphen separated
101110 # app container secrets are lowercase and hyphen separated
102111 secret_name = lower (env. value . name )
112+
113+ dynamic "env" {
114+ for_each = var. secret_variables
115+ content {
116+ # Env vars are uppercase and underscore separated
117+ name = upper (replace (env. key , " -" , " _" ))
118+ # app container secrets are lowercase and hyphen separated
119+ secret_name = replace (lower (env. key ), " _" , " -" )
103120 }
104121 }
105122 }
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
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ resource "azurerm_container_app" "main" {
6464 dynamic "secret" {
6565 for_each = var. secret_variables
6666 content {
67- name = lower (secret. key )
67+ name = replace ( lower (secret. key ), " _ " , " - " )
6868 value = secret. value
6969 }
7070 }
@@ -88,8 +88,8 @@ resource "azurerm_container_app" "main" {
8888 for_each = var. secret_variables
8989 content {
9090 # Env vars are uppercase and underscore separated
91- name = upper (replace (env. key , " -" , " _" ))
92- value = lower (env. key )
91+ name = upper (replace (env. key , " -" , " _" ))
92+ secret_name = replace ( lower (env. key ), " _ " , " - " )
9393 }
9494 }
9595
You can’t perform that action at this time.
0 commit comments