Azure VNET Peering – Terraform
VNET’ler arasında bağlantı oluşturmak (peering) için aşağıdaki terraform kodunu kullanabilirsiniz.
resource "azurerm_resource_group" "msazureturkey" {
name = "peeredvnets-rg"
location = "North Europe"
}
resource "azurerm_virtual_network" "msazureturkey-1" {
name = "msazureturkeynetwork1"
resource_group_name = azurerm_resource_group.msazureturkey.name
address_space = ["10.0.1.0/24"]
location = azurerm_resource_group.msazureturkey.location
}
resource "azurerm_virtual_network" "msazureturkey-2" {
name = "msazureturkeynetwork2"
resource_group_name = azurerm_resource_group.msazureturkey.name
address_space = ["10.0.2.0/24"]
location = azurerm_resource_group.msazureturkey.location
}
resource "azurerm_virtual_network_peering" "msazureturkey-1" {
name = "peer1to2"
resource_group_name = azurerm_resource_group.msazureturkey.name
virtual_network_name = azurerm_virtual_network.msazureturkey-1.name
remote_virtual_network_id = azurerm_virtual_network.msazureturkey-2.id
}
resource "azurerm_virtual_network_peering" "msazureturkey-2" {
name = "peer2to1"
resource_group_name = azurerm_resource_group.msazureturkey.name
virtual_network_name = azurerm_virtual_network.msazureturkey-2.name
remote_virtual_network_id = azurerm_virtual_network.msazureturkey-1.id
}