谁能提供一个示例,说明如何使用Terraform将Azure VM规模集(VMSS)添加到应用程序网关的后端池。
我只能找到one example,无法为我工作。尽管terraform plan
和terraform apply
不会出错,但VMSS不会添加到后端池中。我想知道我的问题是否是由应用程序网关资源的backend_address_pool
输出是一个块而不是单个属性引起的。
我正在使用带有AzureRM提供程序1.31.0的Terraform 0.12.5。
output "name" {
value = azurerm_application_gateway.pool[*].name
}
output "id" {
value = azurerm_application_gateway.pool[*].id
}
output "backend_address_pool" {
value = azurerm_application_gateway.pool[*].backend_address_pool
}
module "vmss_example" {
...
application_gateway_backend_address_pool_ids = ["${module.app_gateway_example[0].id}/backendAddressPools/my-backend-address-pool"]
}
创建资源后,重新运行terraform plan
希望将vmss从以下位置更改:
...
- ip_configuration {
- application_gateway_backend_address_pool_ids = [] -> null
- application_security_group_ids = [] -> null
- load_balancer_backend_address_pool_ids = [] -> null
- load_balancer_inbound_nat_rules_ids = [] -> null
- name = "ipconfig" -> null
- primary = true -> null
- subnet_id = "/subscriptions/#########-####-####-####-############/resourceGroups/demo-modules-rg/providers/Microsoft.Network/virtualNetworks/vnetdemodemo01/subnets/subnetdemovm01" -> null
}
...
收件人:
...
+ ip_configuration {
+ application_gateway_backend_address_pool_ids = (known after apply)
+ application_security_group_ids = []
+ load_balancer_backend_address_pool_ids = []
+ load_balancer_inbound_nat_rules_ids = (known after apply)
+ name = "ipconfig"
+ primary = true
+ subnet_id = "/subscriptions/#########-####-####-####-############/resourceGroups/demo-modules-rg/providers/Microsoft.Network/virtualNetworks/vnetdemodemo01/subnets/subnetdemovm01"
}
...
我认为这意味着它正在尝试更新application_gateway_backend_address_pool_ids
。
任何帮助,指示或建议将不胜感激。 TIA
答案 0 :(得分:1)
是的,您只需要使用application_gateway_backend_address_pool_ids
在ip_configuration块中指定对应用程序网关的后端地址池的引用数组。
例如,这在Terraform v0.12.5上对我有效 + provider.azurerm v1.32.0:
ip_configuration {
name = "TestIPConfiguration"
primary = true
subnet_id = "${azurerm_subnet.backend.id}"
application_gateway_backend_address_pool_ids = "${azurerm_application_gateway.network.backend_address_pool[*].id}"
}
或者,这也可以application_gateway_backend_address_pool_ids = ["${azurerm_application_gateway.network.backend_address_pool[0].id}"]
检查输出
output "backend_address_pool" {
value = "${azurerm_application_gateway.network.backend_address_pool[*].id}"
}