【问题标题】:azurerm_vpn_gateway_connection Unsupported attribute vpn_site_link_idazurerm_vpn_gateway_connection 不支持的属性 vpn_site_link_id
【发布时间】:2023-04-03 01:09:02
【问题描述】:

我们正在尝试使用此处的文档创建 azurerm_vpn_gateway_connection https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/vpn_gateway_connection#bgp_enabled 我们正在使用

resource "azurerm_vpn_gateway_connection" "example" {
  name               = "example"
  vpn_gateway_id     = azurerm_vpn_gateway.example.id
  remote_vpn_site_id = azurerm_vpn_site.example.id

  vpn_link {
    name             = "link1"
    vpn_site_link_id = azurerm_vpn_site.example.vpn_site_link[0].id 
  }

  vpn_link {
    name             = "link2"
    vpn_site_link_id = azurerm_vpn_site.example.vpn_site_link[1].id 
  }
}

我们在运行 terraform plan 时遇到错误

│ Error: Unsupported attribute
│
│   on main.tf line 95, in resource "azurerm_vpn_gateway_connection" "example":
│   95:     vpn_site_link_id = azurerm_vpn_site.example.vpn_site_link[0].id
│
│ This object has no argument, nested block, or exported attribute named "vpn_site_link".
╵

【问题讨论】:

    标签: azure terraform azure-rm hashicorp


    【解决方案1】:

    问题是azurerm_vpn_site 没有属性vpn_site_link。我想也许你想要:

    vpn_site_link_id = azurerm_vpn_site.example.link[0].id
    

    第二种情况类似。

    【讨论】:

    • 该更改产生错误:意外的资源实例键│因为 azurerm_vpn_site.example 没有设置“count”或“for_each”,所以对其的引用不得包含索引键。删除括号内的索引以引用此资源的单个实例。
    • @eiu165 您还没有提供azurerm_vpn_site.example 的定义,所以我不知道它是如何创建的。但我根据错误更新了答案。
    • 我使用了registry.terraform.io/providers/hashicorp/azurerm/latest/docs/…这里的整个示例,我只是没有将整个内容粘贴到问题中
    • @eiu165 不幸的是,文档中的示例不正确,因此您会遇到错误。
    • 是否可以将 vpn_link 添加到 azurerm_vpn_gateway_connection?
    猜你喜欢
    • 2021-12-29
    • 1970-01-01
    • 2021-07-15
    • 2011-10-25
    • 2011-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    相关资源
    最近更新 更多