Azure虚拟网关:无法修改虚拟网络网关Bgp对等地址

h9vpoimq  于 2022-12-24  发布在  其他
关注(0)|答案(1)|浏览(122)

我想设置点到点VPN,但在尝试设置点到点配置时出现以下错误。
使用的地形版本:天青-3.0.2

│ Error: Creating/Updating Virtual Network Gateway: (Name "vpng-connectivity-shared-centralus-001" / Resource Group "rg-connectivity-shared-centralus-001"): network.VirtualNetworkGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="VirtualNetworkGatewayBgpPeeringAddressCannotBeModified" Message="The BgpPeeringAddress for the virtual network gateway /subscriptions/xxxx/resourceGroups/rg-connectivity-shared-centralus-001/providers/Microsoft.Network/virtualNetworkGateways/vpng-connectivity-shared-centralus-001 cannot be modified" Details=[]
│ 
│   with module.create_connectivity_hub_subscription.azurerm_virtual_network_gateway.connectivity-hub-vnet-gateway,
│   on ../../Azure_Terraform_Modules/connectivity_subscription/connectivity_subscription.tf line 558, in resource "azurerm_virtual_network_gateway" "connectivity-hub-vnet-gateway":
│  558: resource "azurerm_virtual_network_gateway" "connectivity-hub-vnet-gateway" {
│ 
╵
##[error]Bash exited with code '1'.

下面是使用的代码

resource "azurerm_virtual_network_gateway" "connectivity-hub-vnet-gateway" {
  name                = "vpng-${var.subscription_type}-shared-${var.location}-001"
  location            = var.location
  resource_group_name = module.create_rg.rg_name

  type     = "Vpn"
  vpn_type = "RouteBased"

  active_active = false
  enable_bgp    = false
  sku           = "VpnGw1"

  ip_configuration {
    name                          = "vnetGatewayConfig"
    public_ip_address_id          = azurerm_public_ip.connectivity-hub-vpn-gateway1-pip.id
    private_ip_address_allocation = "Dynamic"
    subnet_id                     = module.create_gateway_subnet.subnet_id
  }

  vpn_client_configuration {
    address_space = ["172.16.0.0/16"]
    root_certificate {
      name = "ROOTCERT"
      public_cert_data = <<EOF
      MIIC3zCCAcegAwIBAgIQJdWvUysG/oxPlBZu2cCi1DANBgkqhkiG9w0BAQsFADAS
      EOF 
    }
  }

  depends_on = [azurerm_public_ip.connectivity-hub-vpn-gateway1-pip, module.create_gateway_subnet]
  tags       = var.tags
}
nvbavucw

nvbavucw1#

为了达到预期的结果,我运行了下面的terraform脚本,做了一些修改,并将"Azurem"版本设置为3.29.1,或者您可以使用最新版本(3.37.0);它对我起作用了,没有任何错误。
当我在我的环境中尝试它时,我遇到了同样的问题。我包括了三个IP配置,因为创建网关的最低标准是"3"&"2"客户端配置对等地址。

vi main.tf:

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "3.29.1"
    }
  }
}
provider "azurerm" {
  features{}
}
resource "azurerm_resource_group" "xxx" {
  name = "testfirst"
  location = "West Europe"
}
resource "azurerm_virtual_network" "vnet" {
  name                = "<xxxvnet>"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  address_space       = ["10.10.0.0/16"]
}
resource "azurerm_subnet" "xxxGatewaySubnet>" {
  name                 = "xxxGatewaySubnet>"
  resource_group_name  = azurerm_resource_group.rg.name
  virtual_network_name = azurerm_virtual_network.vnet.name
  address_prefixes     = ["10.10.1.0/24"]
}

resource "azurerm_public_ip" "xxip1" {
  name                = "xxip1"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  sku = "Standard"
  allocation_method   = "Static"
}
resource "azurerm_public_ip" "xxip2" {
  name                = "xxip2"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
    sku = "Standard"
  allocation_method   = "Static"
}
resource "azurerm_public_ip" "xxip3" {
  name                = "xxip3"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
    sku = "Standard"
  allocation_method   = "Static"
}
resource "azurerm_virtual_network_gateway" "xxxGateWay" {
  name                = "xxxGateWay"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name

  sku           = "VpnGateway1"
  type          = "Vpn"
  active_active = true
  enable_bgp    = true

  ip_configuration {
    name                          = "xxxvnetGatewayConfig1"
    public_ip_address_id          = azurerm_public_ip.gwip1.id
    private_ip_address_allocation = "Dynamic"
    subnet_id                     = azurerm_subnet.gwsubnet.id
  }
  ip_configuration {
    name                          = "xxxxvnetGatewayConfig2"
    public_ip_address_id          = azurerm_public_ip.gwip2.id
    private_ip_address_allocation = "Dynamic"
    subnet_id                     = azurerm_subnet.gwsubnet.id
  }
 ip_configuration {
    name                          = "xxxvnetGatewayConfig3"
    public_ip_address_id          = azurerm_public_ip.gwip3.id
    private_ip_address_allocation = "Dynamic"
    subnet_id                     = azurerm_subnet.gwsubnet.id
  }
  vpn_client_configuration {
    address_space = ["172.16.0.0/16"]
    root_certificate {
      name = "ROOTCERT"
      public_cert_data = <<EOF
MIIC6zCCAdOgAwIBAgIQdGSy/6KEorFGCYqMgGcJ0TANBgkqhkiG9w0BAQsFADAY
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LMd5oRRrWWIPI2kj6iOk8FGMNUaJ0q4PgEw0Z9kACoklUt6Wj6JaEU4GrfXQ6Ety
HdgWObzfF3I7azJlOM8Go4PE97LXMPRXJep6oOmQVQ==
      EOF 
    }
  }
  bgp_settings {
    asn = 65515
  
    peering_addresses {
      ip_configuration_name = "xxxvnetGatewayConfig1"
      apipa_addresses = ["169.254.21.2", "169.254.22.2"]
    }

    peering_addresses {
      ip_configuration_name = "xxxxvnetGatewayConfig2"
      apipa_addresses = ["169.254.21.6", "169.254.22.6"]
    }
  }
  tags = {
  test = "testpurpose"
  }
}

地形初始化:

地形平面图:

地形应用:

部署后门户中的点到站点配置:

Reference: terraform

相关问题