Skip to content

Commit 57493ea

Browse files
authored
[DTOSS-8589] Fix container app RG data source error (#179)
* Add lowercase virtual network name New resources should be created with lowercase name * Fix error container app error when the RG is not created The data source was relying on the resource group existence and failing when building an environment from scratch
1 parent 08f0db8 commit 57493ea

File tree

8 files changed

+18
-10
lines changed

8 files changed

+18
-10
lines changed

infrastructure/modules/container-app-environment/data.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "azurerm_container_app_environment" "main" {
22
name = var.name
3-
location = data.azurerm_resource_group.main.location
3+
location = var.location
44
resource_group_name = var.resource_group_name
55
log_analytics_workspace_id = var.log_analytics_workspace_id
66
infrastructure_subnet_id = var.vnet_integration_subnet_id

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ variable "resource_group_name" {
88
type = string
99
}
1010

11+
variable "location" {
12+
type = string
13+
description = "The location/region where the container app environment is created."
14+
default = "UK South"
15+
}
16+
1117
variable "log_analytics_workspace_id" {
1218
type = string
1319
description = "ID of the log analytics workspace to send resource logging to via diagnostic settings"

infrastructure/modules/container-app/data.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,3 @@ data "azurerm_key_vault_secrets" "app" {
44

55
key_vault_id = var.app_key_vault_id
66
}
7-
8-
data "azurerm_resource_group" "main" {
9-
name = var.resource_group_name
10-
}

infrastructure/modules/container-app/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module "container_app_identity" {
22
source = "../managed-identity"
33
resource_group_name = var.resource_group_name
4-
location = data.azurerm_resource_group.main.location
4+
location = var.location
55
uai_name = "${var.name}-identity"
66
}
77

@@ -11,7 +11,7 @@ module "key_vault_reader_role" {
1111

1212
source = "../rbac-assignment"
1313

14-
scope = data.azurerm_resource_group.main.id
14+
scope = var.app_key_vault_id
1515
role_definition_name = "Key Vault Secrets User"
1616
principal_id = module.container_app_identity.principal_id
1717
}

infrastructure/modules/container-app/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ variable "name" {
33
type = string
44
}
55

6+
variable "location" {
7+
type = string
8+
description = "The location/region where the container app is created."
9+
default = "UK South"
10+
}
11+
612
variable "container_app_environment_id" {
713
description = "ID of the container app environment."
814
type = string

infrastructure/modules/shared-config/output.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ locals {
157157
virtual-machine = lower("${var.env}-${var.application}")
158158
win-virtual-machine = lower("${var.env}-${var.application}")
159159
virtual-network = upper("VNET-${var.env}-${var.location_map[var.location]}-${var.application}")
160+
virtual-network-lowercase = lower("vnet-${var.env}-${var.location_map[var.location]}-${var.application}")
160161
vnet-gateway = lower("GWY-${var.env}-${var.location_map[var.location]}-${var.application}")
161162
}
162163
}

infrastructure/modules/shared-config/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,6 @@ variable "application" {
9797
variable "tags" {
9898
type = map(string)
9999
description = "Default tags for the deployment"
100+
default = {}
101+
nullable = false
100102
}

0 commit comments

Comments
 (0)