From cbb8b677cfaad9a15f4e67976c31866529120f4e Mon Sep 17 00:00:00 2001 From: Noah Spannbauer Date: Sat, 23 Aug 2025 09:22:51 -0500 Subject: [PATCH] updating modules --- modules/container_app/container_app.tf | 30 ++++++++++++++++++- modules/container_app/variables.tf | 12 ++++++++ .../client_config.tf | 2 ++ .../container_app_environment_storage.tf | 8 +++++ .../variables.tf | 23 ++++++++++++++ modules/storage/outputs.tf | 4 +++ modules/storage/static_website.tf | 6 ---- modules/storage/storage_share.tf | 5 ++++ modules/storage/variables.tf | 13 ++++---- 9 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 modules/container_app_environment_storage/client_config.tf create mode 100644 modules/container_app_environment_storage/container_app_environment_storage.tf create mode 100644 modules/container_app_environment_storage/variables.tf delete mode 100644 modules/storage/static_website.tf create mode 100644 modules/storage/storage_share.tf diff --git a/modules/container_app/container_app.tf b/modules/container_app/container_app.tf index 3286bd8..d57f80e 100644 --- a/modules/container_app/container_app.tf +++ b/modules/container_app/container_app.tf @@ -22,6 +22,24 @@ resource "azurerm_container_app" "container_app_app" { image = container.value["image"] memory = init_container.value["memory"] name = init_container.value["name"] + + dynamic "env" { + for_each = container.value["envs"] != null ? container.value["envs"] : [] + content { + name = env.value["name"] + secret_name = env.value["secret_name"] + value = env.value["value"] + } + } + + dynamic "volume_mounts" { + for_each = container.value["volume_mounts"] != null ? container.value["volume_mounts"] : [] + content { + name = volume_mount.value["name"] + path = volumn_mount.value["path"] + sub_path = volume_mount.value["sub_path"] != null ? volume_mount.value["sub_path"] : null + } + } } } @@ -47,11 +65,21 @@ resource "azurerm_container_app" "container_app_app" { for_each = container.value["volume_mounts"] != null ? container.value["volume_mounts"] : [] content { name = volume_mount.value["name"] - path = volumn_mount.value["path"] + path = volume_mount.value["path"] + sub_path = volume_mount.value["sub_path"] != null ? volume_mount.value["sub_path"] : null } } } } + + dynamic "volume" { + for_each = var.volume + content { + name = volume.value["name"] + storage_type = volume.value["storage_type"] + storage_name = volume.value["storage_name"] + } + } } ingress { diff --git a/modules/container_app/variables.tf b/modules/container_app/variables.tf index 432e7dd..d5401b8 100644 --- a/modules/container_app/variables.tf +++ b/modules/container_app/variables.tf @@ -19,6 +19,7 @@ variable "containers" { volume_mounts = optional(list(object({ name = string path = string + sub_path = optional(string) }))) })) } @@ -82,6 +83,7 @@ variable "init_containers" { volume_mounts = optional(list(object({ name = string path = string + sub_path = optional(string) }))) })) } @@ -135,4 +137,14 @@ variable "template_min_replicas" { variable "template_max_replicas" { default = 1 type = number +} + +variable "volume" { + default = [] + type = list(object({ + name = string + storage_type = string + storage_name = string + share_name = string + })) } \ No newline at end of file diff --git a/modules/container_app_environment_storage/client_config.tf b/modules/container_app_environment_storage/client_config.tf new file mode 100644 index 0000000..38ee13c --- /dev/null +++ b/modules/container_app_environment_storage/client_config.tf @@ -0,0 +1,2 @@ +data "azurerm_client_config" "current" { +} \ No newline at end of file diff --git a/modules/container_app_environment_storage/container_app_environment_storage.tf b/modules/container_app_environment_storage/container_app_environment_storage.tf new file mode 100644 index 0000000..6a27cdb --- /dev/null +++ b/modules/container_app_environment_storage/container_app_environment_storage.tf @@ -0,0 +1,8 @@ +resource "azurerm_container_app_environment_storage" "container_app_environment_storage" { + name = var.name + container_app_environment_id = var.container_app_environment_id + account_name = var.storage_account_name + share_name = var.share_name + access_key = var.storage_account_access_key + access_mode = var.access_mode +} \ No newline at end of file diff --git a/modules/container_app_environment_storage/variables.tf b/modules/container_app_environment_storage/variables.tf new file mode 100644 index 0000000..54a7cc3 --- /dev/null +++ b/modules/container_app_environment_storage/variables.tf @@ -0,0 +1,23 @@ +variable "access_mode" { + type = string +} + +variable "container_app_environment_id" { + type = string +} + +variable "name" { + type = string +} + +variable "share_name" { + type = string +} + +variable "storage_account_access_key" { + type = string +} + +variable "storage_account_name" { + type = string +} \ No newline at end of file diff --git a/modules/storage/outputs.tf b/modules/storage/outputs.tf index 8b09310..77b1773 100644 --- a/modules/storage/outputs.tf +++ b/modules/storage/outputs.tf @@ -1,3 +1,7 @@ output "storage_account_primary_connection_string" { value = azurerm_storage_account.storage_account.primary_connection_string +} + +output "storage_account_name" { + value = azurerm_storage_account.storage_account.name } \ No newline at end of file diff --git a/modules/storage/static_website.tf b/modules/storage/static_website.tf deleted file mode 100644 index a67186c..0000000 --- a/modules/storage/static_website.tf +++ /dev/null @@ -1,6 +0,0 @@ -resource "azurerm_storage_account_static_website" "static_website" { - count = length(var.static_websites) - storage_account_id = azurerm_storage_account.storage_account.id - error_404_document = var.static_websites[count.index].error_404_document - index_document = var.static_websites[count.index].index_document -} \ No newline at end of file diff --git a/modules/storage/storage_share.tf b/modules/storage/storage_share.tf new file mode 100644 index 0000000..70a7424 --- /dev/null +++ b/modules/storage/storage_share.tf @@ -0,0 +1,5 @@ +resource "azure_storage_share" "storage_share" { + count = length(var.storage_shares) + name = var.storage_shares[count.index] + storage_account_name = azurerm_storage_account.storage_account.name +} \ No newline at end of file diff --git a/modules/storage/variables.tf b/modules/storage/variables.tf index 8f40be7..049d9ba 100644 --- a/modules/storage/variables.tf +++ b/modules/storage/variables.tf @@ -12,14 +12,6 @@ variable "resource_group_name" { type = string } -variable "static_websites" { - default = [] - type = list(object({ - error_404_document = string - index_document = string - })) -} - variable "storage_account_name" { type = string } @@ -45,6 +37,11 @@ variable "storage_queues" { type = list(string) } +variable "storage_shares" { + default = [] + type = list(string) +} + variable "storage_tables" { default = [] type = list(string)