Skip to content

Commit 0465b71

Browse files
committed
Better handle network location
1 parent f328f49 commit 0465b71

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

infra/{{app_name}}/database/main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ locals {
1313
resource_group_name = "${local.prefix}${local.database_config.resource_group_name}"
1414

1515
infra_admin_config = module.project_config.infra_admins[local.environment_config.account_name]
16+
17+
network_config = module.project_config.network_configs[local.environment_config.network_name]
18+
19+
location = try(local.network_config.network.location, module.project_config.default_region)
1620
}
1721

1822
terraform {
@@ -73,7 +77,7 @@ module "network" {
7377

7478
resource "azurerm_resource_group" "db" {
7579
name = local.resource_group_name
76-
location = module.project_config.default_region
80+
location = local.location
7781
}
7882

7983
module "database" {
@@ -93,6 +97,6 @@ module "database" {
9397
network_resource_group_name = module.network.resource_group_name
9498

9599
dns_zone_id = data.azurerm_private_dns_zone.db.id
96-
location = module.project_config.default_region
100+
location = azurerm_resource_group.db.location
97101
flex_sku_name = "B_Standard_B1ms"
98102
}

infra/{{app_name}}/service/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ locals {
1717
service_name = "${local.prefix}${local.service_config.service_name}"
1818
resource_group_name = "${local.service_config.service_name}-service"
1919

20-
location = module.project_config.default_region
21-
2220
network_config = module.project_config.network_configs[local.environment_config.network_name]
2321
private_endpoints_subnet = lookup(module.network.subnets, try(local.network_config.network.private_endpoints_subnet_name, ""), null)
22+
23+
location = try(local.network_config.network.location, module.project_config.default_region)
2424
}
2525

2626
terraform {

0 commit comments

Comments
 (0)