Skip to content

Commit

Permalink
fix: Use vnet resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dploeger committed Jun 9, 2021
1 parent bfb3091 commit 4099c22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 2 additions & 7 deletions connections.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 4099c22

Please sign in to comment.