From 4099c2258026ca9126bfebc1814eaa27291cf295 Mon Sep 17 00:00:00 2001 From: Dennis Ploeger Date: Wed, 9 Jun 2021 13:29:29 +0200 Subject: [PATCH] fix: Use vnet resource --- connections.tf | 9 ++------- vars.tf | 9 ++++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/connections.tf b/connections.tf index 6741b95..5ce59e3 100644 --- a/connections.tf +++ b/connections.tf @@ -28,14 +28,9 @@ resource "azurerm_virtual_network_gateway_connection" "connection" { } } -data "azurerm_virtual_network" "target_vnet" { - name = var.target_vnet_name - resource_group_name = var.resource_group -} - resource "azurerm_virtual_network_peering" "peeringvpn" { name = "${lower(var.project)}${lower(var.stage)}netpeering" - remote_virtual_network_id = data.azurerm_virtual_network.target_vnet.id + remote_virtual_network_id = var.target_vnet.id resource_group_name = var.resource_group virtual_network_name = azurerm_virtual_network.vpnnet.name @@ -48,7 +43,7 @@ resource "azurerm_virtual_network_peering" "peeringvpnrev" { name = "${lower(var.project)}${lower(var.stage)}netpeeringrev" remote_virtual_network_id = azurerm_virtual_network.vpnnet.id resource_group_name = var.resource_group - virtual_network_name = var.target_vnet_name + virtual_network_name = var.target_vnet.name allow_gateway_transit = false allow_forwarded_traffic = true diff --git a/vars.tf b/vars.tf index 21a7918..7e929a1 100644 --- a/vars.tf +++ b/vars.tf @@ -29,9 +29,12 @@ variable "vnetgwsku" { default = "VpnGw1" } -variable "target_vnet_name" { - type = string - description = "Name of the target virtual network" +variable "target_vnet" { + type = object({ + id = string + name = string + }) + description = "The Terraform resource of the target vnet" } variable "local_nets" {