我使用下面的代码创建子网,但是字段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”的值不正确:所需的字符串列表。
答案 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
}