Skip to content

Commit c4b7ec7

Browse files
committed
testing123
1 parent 55f9b41 commit c4b7ec7

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

infrastructure/modules/container-app-job/main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

infrastructure/modules/container-app-job/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
7985
variable "job_parallelism" {
8086
description = "The number of replicas that can run in parallel."
8187
type = number

infrastructure/modules/container-app/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)