我想在模块块中使用计数,但由于不支持我试图用 for 循环编写 for_each 但它给出了"for_each" argument value is unsuitable
错误。
我无法将计数传递给内部模块,因为它会弄乱我的输出格式。有人可以指导我如何正确调用 for_each。
主文件
module "test" {
for_each = toset([for id in range(2): {
index = id
}])
source = "./am"
name = each.value
}
output "all" {
depends_on = [ module.test ]
value = module.one
}
上午/test.tf
variable "name" {
type = string
}
resource "azurerm_public_ip" "ip" {
name = ..
resource_group_name = ..
location = ..
allocation_method = ..
}
output "one" {
description = "one_value"
value = azurerm_public_ip.ip.ip_address
}