Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Fix resource group circular dependency if vnet_location is specified #63

Closed
Closed
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
9 changes: 5 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#Azure Generic vNet Module
data "azurerm_resource_group" "vnet" {
name = var.resource_group_name
count = var.vnet_location != null ? 0 : 1
name = var.resource_group_name
}

resource "azurerm_virtual_network" "vnet" {
name = var.vnet_name
resource_group_name = data.azurerm_resource_group.vnet.name
location = var.vnet_location != null ? var.vnet_location : data.azurerm_resource_group.vnet.location
resource_group_name = var.resource_group_name
location = var.vnet_location != null ? var.vnet_location : data.azurerm_resource_group.vnet[0].location
address_space = var.address_space
dns_servers = var.dns_servers
tags = var.tags
Expand All @@ -15,7 +16,7 @@ resource "azurerm_virtual_network" "vnet" {
resource "azurerm_subnet" "subnet" {
count = length(var.subnet_names)
name = var.subnet_names[count.index]
resource_group_name = data.azurerm_resource_group.vnet.name
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.vnet.name
address_prefixes = [var.subnet_prefixes[count.index]]
service_endpoints = lookup(var.subnet_service_endpoints, var.subnet_names[count.index], null)
Expand Down