首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Terraform Azure网络安全

Terraform Azure网络安全
EN

Stack Overflow用户
提问于 2018-01-31 19:01:41
回答 2查看 8.6K关注 0票数 5

我试图通过Terraform为Azure中的网络安全组配置具有多个源地址的网络安全规则。

基于文档的rule.html

然而,我无法让它发挥作用,也找不到任何例子:

prefixes

我知道错误:

错误: azurerm_network_security_rule.test0:"source_address_prefix":必需字段未设置错误: azurerm_network_security_rule.test0::无效或未知键: source_address_prefixes

这是我的样本:

代码语言:javascript
复制
resource "azurerm_network_security_rule" "test0" {
name = "RDP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "TCP"
source_port_range = "*"
destination_port_range = "3389"
source_address_prefixes = "{200.160.200.30,200.160.200.60}"
destination_address_prefix = "VirtualNetwork"
network_security_group_name= "${azurerm_network_security_group.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
}

请让我知道。

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-02-02 01:54:40

source_address_prefixes需要源地址前缀列表。

修改如下:

代码语言:javascript
复制
source_address_prefixes = ["200.160.200.30","200.160.200.60"]

azurerm_network_security_group.test.name中也有一个错误,正确的类型是azurerm_network_security_group.test0.name。下面的tf文件适用于我。

代码语言:javascript
复制
resource "azurerm_resource_group" "test0" {
  name     = "shuinsg"
  location = "West US"
}

resource "azurerm_network_security_group" "test0" {
  name                = "shuinsgtest"
  location            = "${azurerm_resource_group.test0.location}"
  resource_group_name = "${azurerm_resource_group.test0.name}"
}


resource "azurerm_network_security_rule" "test0" {
name = "RDP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "TCP"
source_port_range = "*"
destination_port_range = "3389"
source_address_prefixes = ["200.160.200.30","200.160.200.60"]
destination_address_prefix = "VirtualNetwork"
network_security_group_name= "${azurerm_network_security_group.test0.name}"
resource_group_name = "${azurerm_resource_group.test0.name}"
}

这是我的测试结果。

票数 7
EN

Stack Overflow用户

发布于 2018-02-01 14:22:50

"address_prefix“是表示CIDR (例如10.0.0.0/24 )的字符串值。因此,在您的例子中,source_address_prefix = "200.160.200.30/32"destination_address_prefix = "${azurerm_virtual_network.test.address_space.0}"取决于您想要引用的内容。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48549577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档