【发布时间】:2021-01-27 03:17:05
【问题描述】:
我正在尝试创建一种动态方法来在最终用户配置的多个环境中创建虚拟机。 尝试使用嵌套循环进行循环。扁平化功能、计数等,但还没有找到实现目标的方法。 我有具有以下结构的 terrafrom.tfvars:
Bigip_devices = {
main_hub = {
region = "eastus"
azs = ["1"] #Azure availabilty zones
vnet_name = "vnet-main" # Vnet name to deploy to
bigip_instance_count = 2 # Number of instnaces to delpoy
cluster = "yes" # Deploy as a cluster or stand alone device
version = "" # Leave blank for default value
sku = "" # Leave blank for default value - f5-bigip-virtual-edition-25m-best-hourly
offer = "" # Leave blank for default value - f5-big-ip-best
instance_type = "" # Leave blank for default value - Standard_DS3_v2
disable_password_authentication = "" #Leave blank for default value
tags = ""
}
spoke = {
region = "eastus"
azs = ["1","2"] #Azure availabilty zones
vnet_name = "vnet-spoke" # Vnet name to deploy to
bigip_instance_count = 4 # Number of instnaces to delpoy
cluster = "yes" # Deploy as a cluster or stand alone device
version = "" # Leave blank for default value
sku = "" # Leave blank for default value - f5-bigip-virtual-edition-25m-best-hourly
offer = "" # Leave blank for default value - f5-big-ip-best
instance_type = "" # Leave blank for default value - Standard_DS3_v2
disable_password_authentication = "" #Leave blank for default value
tags = ""
}
}
迭代列表中的每个键(在示例中是 2 个键 - 主集线器和辐条)并创建与 bigip_instance_count 设置对应的虚拟机数量的正确方法是什么。 在上面的示例中,我想创建 2 个环境,一个有 2 个设备,第二个有 4 个设备。 有没有办法实现?
【问题讨论】:
标签: terraform terraform-provider-azure terraform0.12+