我的计划是在同一安全规则上允许ICMP和TCP协议,但我遇到了与“属性值类型”相关的问题
我的地形代码:
resource "azurerm_network_security_group" "example" {
name = "01-tf-SG"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
security_rule {
name = "test123"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = **["Icmp", "Tcp"]** ---> iT FAILS!!!
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "172.16.25.10/32"
destination_address_prefix = "10.0.1.10/32"
}
我没有在terraform repo中找到任何例子:https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_rule
能够在同一安全规则协议字段上使用多个协议。
3条答案
按热度按时间hfsqlsce1#
由于
Mark B
在他的回答中列出,您无法为protocol
提供一个列表。xurqigkl2#
谢谢@chris Doyle。你的解决方案是最有效的。
注意,你忘记了toset函数中的**[ ]**,所以最终的代码应该是:
结果:
kd3sttzy3#
协议属性doesn't accept a list。您可能需要创建两个安全规则,或者使用
*
作为协议。