我正在尝试结合使用 random_id 属性和 count 元属性来创建多个具有唯一名称的 Azure 存储帐户。
配置代码:
# Create storage accounts
resource "random_id" "storage_account_name_unique" {
byte_length = 8
}
resource "azurerm_storage_account" "storage" {
count = "${var.storage_account_count}"
name = "tfsta${lower(random_id.storage_account_name_unique.hex)}"
resource_group_name = "${azurerm_resource_group.rg.name}"
location = "${azurerm_resource_group.rg.location}"
account_kind = "StorageV2"
account_tier = "Standard"
access_tier = "Hot"
account_replication_type = "${var.account_replication_type}"
network_rules {
ip_rules = ["127.0.0.1"]
virtual_network_subnet_ids = ["${azurerm_subnet.subnet.id}"]
}
tags = "${var.tags}"
}
Run Code Online (Sandbox Code Playgroud)
这段代码的问题:
选定的 Terraform Apply 输出:
此输出显示 Terraform 认为它正在创建三个具有相同 random_id 的独立存储帐户。计划已成功应用,但在 …