创建带有address_prefixes错误的子网

时间:2020-09-17 08:03:56

标签: terraform terraform-provider-azure

我使用下面的代码创建子网,但是字段address_prefixes显示以下错误。请指导。

resource "azurerm_subnet" "datbrick_subnet" {
 count                   = length(var.subnet_address)
 name                    = element(var.subnet_name, count.index) 
 address_prefixes          =  element(var.subnet_address, count.index)
 resource_group_name      = var.subscriptionrg_name
 virtual_network_name     = var.vnet_name
 }
  variable "subnet_address" {
  default = ["10.0.0.0/26", "10.0.1.0/26"]
  }

count.index为1 | var.subnet_address是具有2个元素的元组。属性“ address_prefixes”的值不正确:所需的字符串列表。

1 个答案:

答案 0 :(得分:0)

您的address_prefixes应该是列表。请尝试以下操作:

resource "azurerm_subnet" "datbrick_subnet" {
 count                   = length(var.subnet_address)
 name                    = element(var.subnet_name, count.index) 
 address_prefixes        = [element(var.subnet_address, count.index)]
 resource_group_name     = var.subscriptionrg_name
 virtual_network_name    = var.vnet_name
 }