gpt4 book ai didi

azure - 将 VM 规模集附加到应用程序网关的后端池

转载 作者:行者123 更新时间:2023-12-02 07:46:37 26 4
gpt4 key购买 nike

谁能提供一个示例,说明如何使用 Terraform 将 Azure VM 规模集 (VMSS) 添加到应用程序网关的后端池。

我只能找到one example我无法为自己工作。尽管 terraform planterraform apply 不会出错,但 VMSS 不会添加到后端池中。我想知道我的问题是否是由于应用程序网关资源的 backend_address_pool 输出是一个 block 而不是单个属性引起的。

我正在使用 Terraform 0.12.5 和 AzureRM 提供程序 1.31.0。

应用程序网关资源输出:

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
}

VMSS 模块声明:

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

最佳答案

是的,您只需使用 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}"
}

enter image description here

关于azure - 将 VM 规模集附加到应用程序网关的后端池,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57267244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com