gpt4 book ai didi

azure - azurerm_lb 此处不需要指定的 Terraform 错误参数

转载 作者:行者123 更新时间:2023-12-03 01:19:32 24 4
gpt4 key购买 nike

我正在运行下面的代码,得到的参数不是预期的,但参数在 terraform 文档中。请指教。变量.tf 文件

      type = list(object(
{
lb_name = string
sku = string
location = string
lb_resource_group_name = string
vnet_name = string
vnet_resource_group_name = string
subnet_name = string
frontend_ip_config = list(object({
frontend_ip_name = string
private_ip_address = string
}))
}
))
description = "lb creation"
}

main.tf

resource "azurerm_lb" "lb" {
for_each = { for lb in var.load_balancer : lb.lb_name => lb }
name = each.value.lb_name
sku = each.value.sku
location = each.value.location
resource_group_name = each.value.lb_resource_group_name

dynamic "frontend_ip_configuration" {
for_each = { for fip in each.value.frontend_ip_config : fip.frontend_ip_name => fip }
name = frontend_ip_configuration.value.frontend_ip_name
subnet_id = data.azurerm_subnet.subnet[each.value.lb_name].id
private_ip_address = frontend_ip_configuration.value.private_ip_address
private_ip_address_allocation = frontend_ip_configuration.value.private_ip_address == null ? "Dynamic" : "Static"
}
}

错误

"msg": "Failed to validate Terraform configuration files:\r\n\u001b[31m╷\u001b[0m\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[1m\u001b[31mError: \u001b[0m\u001b[0m\u001b[1mUnsupported argument\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[0m  on private-link-module/private-link-service.tf line 17, in resource \"azurerm_lb\" \"lb\":\n\u001b[31m│\u001b[0m \u001b[0m  17:     \u001b[4mname\u001b[0m                          = frontend_ip_configuration.value.frontend_ip_name\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0mAn argument named \"name\" is not expected here.\n\u001b[31m╵\u001b[0m\u001b[0m\n\u001b[31m╷\u001b[0m\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[1m\u001b[31mError: \u001b[0m\u001b[0m\u001b[1mUnsupported argument\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[0m  on private-link-module/private-link-service.tf line 18, in resource \"azurerm_lb\" \"lb\":\n\u001b[31m│\u001b[0m \u001b[0m  18:     \u001b[4msubnet_id\u001b[0m                     = data.azurerm_subnet.subnet[each.value.lb_name].id  \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0mAn argument named \"subnet_id\" is not expected here.\n\u001b[31m╵\u001b[0m\u001b[0m\n\u001b[31m╷\u001b[0m\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[1m\u001b[31mError: \u001b[0m\u001b[0m\u001b[1mUnsupported argument\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[0m  on private-link-module/private-link-service.tf line 19, in resource \"azurerm_lb\" \"lb\":\n\u001b[31m│\u001b[0m \u001b[0m  19:     \u001b[4mprivate_ip_address\u001b[0m            = frontend_ip_configuration.value.private_ip_address\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0mAn argument named \"private_ip_address\" is not expected here.\n\u001b[31m╵\u001b[0m\u001b[0m\n\u001b[31m╷\u001b[0m\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[1m\u001b[31mError: \u001b[0m\u001b[0m\u001b[1mUnsupported argument\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\u001b[0m  on private-link-module/private-link-service.tf line 20, in resource \"azurerm_lb\" \"lb\":\n\u001b[31m│\u001b[0m \u001b[0m  20:     \u001b[4mprivate_ip_address_allocation\u001b[0m = frontend_ip_configuration.value.private_ip_address == null ? \"Dynamic\" : \"Static\"\u001b[0m\n\u001b[31m│\u001b[0m \u001b[0m\n\u001b[31m│\u001b[0m \u001b[0mAn argument named \"private_ip_address_allocation\" is not expected here.\n\u001b[31m╵\u001b[0m\u001b[0m\n",

提供商版本:版本=“2.98.0”

地形版本:“~> 1.1.7”

最佳答案

您忘记了内容。应该是:

  dynamic "frontend_ip_configuration" {
for_each = { for fip in each.value.frontend_ip_config : fip.frontend_ip_name => fip }

content {
name = frontend_ip_configuration.value.frontend_ip_name
subnet_id = data.azurerm_subnet.subnet[frontend_ip_configuration.value.lb_name].id
private_ip_address = frontend_ip_configuration.value.private_ip_address
private_ip_address_allocation = frontend_ip_configuration.value.private_ip_address == null ? "Dynamic" : "Static"
}

}

关于azure - azurerm_lb 此处不需要指定的 Terraform 错误参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72174302/

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