Vnet 对等互连不会在 azure 中被删除
Vnet peering not getting deleted in azure
我正在尝试 create/delete 使用 terraform 在 azure 中建立 vnet 对等连接。为了提供一些上下文,有两个 vnets-A 和 B,在两个不同的订阅下但在同一个 AD 中,我可以访问两者。 Vnet A 是静态的,vnetB 是按需创建的。
我可以通过从 vnet B 启动来创建对等互连。但是当我从 Vnet B 中删除对等互连并删除 vNet B 的整个资源组并重新创建资源组和对等互连时,它说-
Error: Cannot create or update peering vnetB. Virtual networks -vnetB and vnetA cannot be peered because address space of the first virtual network overlaps with address space of vnet already peered with the second virtual network. Overlapping address prefixes: 10.2.65.0/25.
我可以看到对等互连没有从 vnet A 中删除。有没有办法删除这个对等互连?
地形文件:
# It is assumed that A already has a resource group and vnet created
# Access the static A account
provider "azurerm" {
alias = "A"
subscription_id = "XXXX-XXXX-XXXX"
features {}
skip_provider_registration = true
}
data "azurerm_resources" "vnet" {
resource_group_name = "A-ResourceGroup"
type = "Microsoft.Network/virtualNetworks"
provider = azurerm.Aprov
}
resource "azurerm_virtual_network_peering" "A-B" {
provider = azurerm.Aprov
name = "A-B"
resource_group_name = data.azurerm_resources.vnet.resource_group_name
virtual_network_name = data.azurerm_resources.vnet.resources[0].name
remote_virtual_network_id = azurerm_virtual_network.B-vnet.id
}
# Deployment in B Account
provider "azurerm" {
skip_provider_registration = true
features {}
}
resource "azurerm_resource_group" "B" {
name = "B-peer-1"
location = "West US"
}
resource "azurerm_virtual_network" "B-vnet" {
name = "B-network1"
resource_group_name = azurerm_resource_group.B.name
address_space = ["10.0.1.0/24"]
location = "West US"
}
# Add the VNET peering to A account
resource "azurerm_virtual_network_peering" "B-A" {
name = "B-A"
resource_group_name = azurerm_resource_group.B.name
virtual_network_name = azurerm_virtual_network.B-vnet.name
remote_virtual_network_id = data.azurerm_resources.vnet.resources[0].id
}
为了重现您的问题,请在同一区域创建 VNETA 和 VNET B,并将它们对等
VNETA 到 VNETB 对等互连
VNETB 到 VNETA 对等互连
现在我删除了 VNETB
,但它仍然会与 VNETA
对等,除非我们不删除或删除对等。
但是,您正在创建相同的 VNETB 或使用不同的名称但具有相同的地址 space 它会说您无法对等,因为您已经在对等中,并且会像您遇到的那样抛出错误。
您可以从门户本身删除现有对等互连。
您还可以使用 terraform 命令破坏现有的对等 terraform destroy -target nameofpeering
我正在尝试 create/delete 使用 terraform 在 azure 中建立 vnet 对等连接。为了提供一些上下文,有两个 vnets-A 和 B,在两个不同的订阅下但在同一个 AD 中,我可以访问两者。 Vnet A 是静态的,vnetB 是按需创建的。
我可以通过从 vnet B 启动来创建对等互连。但是当我从 Vnet B 中删除对等互连并删除 vNet B 的整个资源组并重新创建资源组和对等互连时,它说-
Error: Cannot create or update peering vnetB. Virtual networks -vnetB and vnetA cannot be peered because address space of the first virtual network overlaps with address space of vnet already peered with the second virtual network. Overlapping address prefixes: 10.2.65.0/25.
我可以看到对等互连没有从 vnet A 中删除。有没有办法删除这个对等互连?
地形文件:
# It is assumed that A already has a resource group and vnet created
# Access the static A account
provider "azurerm" {
alias = "A"
subscription_id = "XXXX-XXXX-XXXX"
features {}
skip_provider_registration = true
}
data "azurerm_resources" "vnet" {
resource_group_name = "A-ResourceGroup"
type = "Microsoft.Network/virtualNetworks"
provider = azurerm.Aprov
}
resource "azurerm_virtual_network_peering" "A-B" {
provider = azurerm.Aprov
name = "A-B"
resource_group_name = data.azurerm_resources.vnet.resource_group_name
virtual_network_name = data.azurerm_resources.vnet.resources[0].name
remote_virtual_network_id = azurerm_virtual_network.B-vnet.id
}
# Deployment in B Account
provider "azurerm" {
skip_provider_registration = true
features {}
}
resource "azurerm_resource_group" "B" {
name = "B-peer-1"
location = "West US"
}
resource "azurerm_virtual_network" "B-vnet" {
name = "B-network1"
resource_group_name = azurerm_resource_group.B.name
address_space = ["10.0.1.0/24"]
location = "West US"
}
# Add the VNET peering to A account
resource "azurerm_virtual_network_peering" "B-A" {
name = "B-A"
resource_group_name = azurerm_resource_group.B.name
virtual_network_name = azurerm_virtual_network.B-vnet.name
remote_virtual_network_id = data.azurerm_resources.vnet.resources[0].id
}
为了重现您的问题,请在同一区域创建 VNETA 和 VNET B,并将它们对等
VNETA 到 VNETB 对等互连
VNETB 到 VNETA 对等互连
现在我删除了 VNETB
,但它仍然会与 VNETA
对等,除非我们不删除或删除对等。
但是,您正在创建相同的 VNETB 或使用不同的名称但具有相同的地址 space 它会说您无法对等,因为您已经在对等中,并且会像您遇到的那样抛出错误。
您可以从门户本身删除现有对等互连。
您还可以使用 terraform 命令破坏现有的对等 terraform destroy -target nameofpeering