我实现了一个服务总线命名空间,它通过ARM模板绑定到一个VNet。所以它只能从我们的VNet访问。我使用了微软的ARM模板。现在我想用地形来达到同样的效果,我该怎么做呢?
rxztt3cl1#
使用下面的代码基于terraform,它将创建.源代码从[code][1]主tf文件
resource "azurerm_subnet" "example" { name = "default" resource_group_name = azurerm_resource_group.example.name virtual_network_name = azurerm_virtual_network.example.name address_prefixes = ["172.17.0.0/24"] service_endpoints = ["Microsoft.ServiceBus"] } resource "azurerm_servicebus_namespace_network_rule_set" "example" { namespace_id = azurerm_servicebus_namespace.example.id default_action = "Deny" public_network_access_enabled = true network_rules { subnet_id = azurerm_subnet.example.id ignore_missing_vnet_service_endpoint = false } }
mwngjboj2#
按照官方示例使用azurerm_servicebus_namespace_network_rule_set:
mv1qrgav3#
我已经通过terraform复制了相同的内容。为了管理ServiceBus命名空间网络规则集,请从-hashicorp中找到以下repo代码
provider "azurerm" { features {} } resource "azurerm_resource_group" "example" { name = "*******" location = "East US" } resource "azurerm_servicebus_namespace" "example" { name = "exam-sb-namespace" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name sku = "Premium" capacity = 1 } resource "azurerm_virtual_network" "example" { name = "exam-vnet" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name address_space = ["172.17.0.0/16"] dns_servers = ["10.0.0.4", "10.0.0.5"] } resource "azurerm_subnet" "example" { name = "default" resource_group_name = azurerm_resource_group.example.name virtual_network_name = azurerm_virtual_network.example.name address_prefixes = ["172.17.0.0/24"] service_endpoints = ["Microsoft.ServiceBus"] } resource "azurerm_servicebus_namespace_network_rule_set" "example" { namespace_id = azurerm_servicebus_namespace.example.id default_action = "Deny" public_network_access_enabled = true network_rules { subnet_id = azurerm_subnet.example.id ignore_missing_vnet_service_endpoint = false } ip_rules = ["1.1.1.1"] }
terraform { required_version = "~>1.3.3" required_providers { azurerm = { source = "hashicorp/azurerm" version = ">=3.5.0" } } }
输出如下:运行计划时应用时从门户网站
3条答案
按热度按时间rxztt3cl1#
使用下面的代码基于terraform,它将创建.源代码从[code][1]主tf文件
mwngjboj2#
按照官方示例使用azurerm_servicebus_namespace_network_rule_set:
mv1qrgav3#
我已经通过terraform复制了相同的内容。为了管理ServiceBus命名空间网络规则集,请从-hashicorp中找到以下repo代码
输出如下:运行计划
时
应用
时
从门户网站