Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions infra/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
locals {
normalized_prefix = lower(replace("${var.name_prefix}${var.environment}", "-", ""))
container_app_environment_name = var.existing_container_app_environment_name != "" ? var.existing_container_app_environment_name : "${var.name_prefix}-${var.environment}-acae"
container_app_environment_id = var.existing_container_app_environment_name != "" ? data.azurerm_container_app_environment.main[0].id : azurerm_container_app_environment.main[0].id
backend_service_names = [
"avatar",
"configuration",
Expand Down Expand Up @@ -149,10 +151,20 @@ resource "azurerm_private_dns_zone_virtual_network_link" "cosmos" {
}

data "azurerm_container_app_environment" "main" {
name = var.existing_container_app_environment_name != "" ? var.existing_container_app_environment_name : "${var.name_prefix}-${var.environment}-acae"
count = var.existing_container_app_environment_name != "" ? 1 : 0
name = local.container_app_environment_name
resource_group_name = azurerm_resource_group.main.name
}

resource "azurerm_container_app_environment" "main" {
count = var.existing_container_app_environment_name == "" ? 1 : 0
name = local.container_app_environment_name
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
log_analytics_workspace_id = azurerm_log_analytics_workspace.main.id
infrastructure_subnet_id = var.aca_vnet_integration_enabled ? azurerm_subnet.aca_infrastructure[0].id : null
}

resource "azurerm_container_registry" "main" {
name = "${local.normalized_prefix}${random_string.suffix.result}acr"
resource_group_name = azurerm_resource_group.main.name
Expand Down Expand Up @@ -259,7 +271,7 @@ resource "azurerm_container_app" "backend_services" {
for_each = toset(local.backend_service_names)

name = "${var.name_prefix}-${each.key}-${var.environment}"
container_app_environment_id = data.azurerm_container_app_environment.main.id
container_app_environment_id = local.container_app_environment_id
resource_group_name = azurerm_resource_group.main.name
revision_mode = "Single"

Expand Down
Loading