From bc6720b56eb35f6d3dd79fe2bd0faa1d37702e85 Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Mon, 18 Aug 2025 09:14:38 -0500 Subject: [PATCH] updating modules --- modules/container_app/container_app.tf | 26 ++++++- modules/container_app/variables.tf | 81 +++++++++++++------- modules/container_app_environment/outputs.tf | 3 + 3 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 modules/container_app_environment/outputs.tf diff --git a/modules/container_app/container_app.tf b/modules/container_app/container_app.tf index 3bb011d..9c230a2 100644 --- a/modules/container_app/container_app.tf +++ b/modules/container_app/container_app.tf @@ -17,20 +17,38 @@ resource "azurerm_container_app" "container_app_app" { dynamic "init_container" { for_each = var.init_containers content { - name = init_container.value["name"] - image = container.value["image"] cpu = init_container.value["cpu"] + image = container.value["image"] memory = init_container.value["memory"] + name = init_container.value["name"] } } dynamic "container" { for_each = var.containers content { - name = container.value["name"] - image = container.value["image"] + command = container.value["command"] cpu = container.value["cpu"] + image = container.value["image"] memory = container.value["memory"] + name = container.value["name"] + + dynamic "env" { + for_each = container.value["envs"] + content { + name = env.value["name"] + secret_name = env.value["secret_name"] + value = env.value["value"] + } + } + + dynamic "volume_mount" { + for_each = container.value["volume_mounts"] + content { + name = volume_mount.value["name"] + path = volumn_mount.value["path"] + } + } } } } diff --git a/modules/container_app/variables.tf b/modules/container_app/variables.tf index bd4c9bb..5ac6c46 100644 --- a/modules/container_app/variables.tf +++ b/modules/container_app/variables.tf @@ -3,13 +3,23 @@ variable "app_subdomain_name" { } variable "containers" { - type = list(object({ - name = string - image = string - cpu = string - memory = string - })) default = [] + type = list(object({ + command = optional(string) + cpu = optional(string) + env = optional(list(object({ + name = string + secret_name = optional(string) + value = optional(string) + }))) + image = string + memory = optional(string) + name = string + volume_mounts = optional(list(object({ + name = string + path = string + }))) + })) } variable "container_app_name" { @@ -21,33 +31,16 @@ variable "container_app_environment_id" { } variable "custom_domain_count" { - type = string -} - -variable "init_containers" { - default = [] - type = list(object({ - name = string - image = string - cpu = string - memory = string - })) -} - -variable "registry_password" { - sensitive = true - type = string -} - -variable "registry_username" { - type = string -} - -variable "domain_name" { + default = 0 type = string } variable "dns_zone_resource_group" { + default = "" + type = string +} + +variable "domain_name" { type = string } @@ -70,6 +63,35 @@ variable "ingress_transport" { type = string } +variable "init_containers" { + default = [] + type = list(object({ + command = optional(string) + cpu = optional(string) + envs = optional(list(object({ + name = string + secret_name = optional(string) + value = optional(string) + }))) + image = string + memory = optional(string) + name = string + volume_mounts = optional(list(object({ + name = string + path = string + }))) + })) +} + +variable "registry_password" { + sensitive = true + type = string +} + +variable "registry_username" { + type = string +} + variable "registry_password_secret_name" { default = "docker-io-password" type = string @@ -93,6 +115,7 @@ variable "secrets" { } variable "storage_account_primary_connection_string" { + default = "" type = string } diff --git a/modules/container_app_environment/outputs.tf b/modules/container_app_environment/outputs.tf new file mode 100644 index 0000000..9b3e066 --- /dev/null +++ b/modules/container_app_environment/outputs.tf @@ -0,0 +1,3 @@ +output "container_app_environment_id" { + value = azurerm_container_app_environment.container_app_environment.id +} \ No newline at end of file