Terraform 无法在 Azure 中创建虚拟网络

Terraform 无法在 Azure 中创建虚拟网络

几天以来,我无法在任何资源组中创建虚拟网络。我收到以下消息

Error: Error applying plan:

1 error(s) occurred:

* azurerm_virtual_network.qmlnetwork: 1 error(s) occurred:

* azurerm_virtual_network.qmlnetwork: Error waiting for completion of Virtual Network "qumulate_network" (Resource Group "QumulateCi"): Long running operation terminated with status 'Failed': Code="InternalServerError" Message="An error occurred."

我尝试更改名称、IP 范围。尝试创建一个全新的资源组。完全清理 Terraform 工作区。没有帮助。这是我的代码。

resource "azurerm_virtual_network" "qmlnetwork" {
name        = "${var.network_name}"
address_space   = ["10.4.0.0/24"]
location    = "${azurerm_resource_group.myproductterraform.location}"
resource_group_name = "${azurerm_resource_group.myproductterraform.name}"
}

/* Add subnet */
resource "azurerm_subnet" "qmlsubnet" {
  name                 = "${var.myproduct_subnet}"
  resource_group_name  = "${azurerm_resource_group.myproductterraform.name}"
  virtual_network_name = "${azurerm_virtual_network.qmlnetwork.name}"
  address_prefix       = "10.4.0.0/24"
}

答案1

谢谢你的回答,你说得对。创建 VNet 时,需要在其中创建子网。修改 tf 如下:

# create virtual network
resource "azurerm_virtual_network" "vnet" {
    name = "tfvnet"
    address_space = ["10.0.0.0/16"]
    location = "ukwest"
    resource_group_name = "${azurerm_resource_group.rg.name}"
    ##You need create a subnet in VNet.
    subnet {
        name = "subnet1"
        address_prefix = "10.0.3.0/24"

    }
} 

您还可以检查一下例子在官方文件上。

答案2

某些地区正在发生中断。据我们了解,Terraform 尝试部署具有空子网定义的 VNET。这是一个有效的操作,因为子网定义不是强制性的(https://docs.microsoft.com/en-us/azure/templates/microsoft.network/virtualnetworks#VirtualNetworkPropertiesFormat

相关内容