Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement to azurerm_servicebus_namespace_network_rule_set: Support 'allow trusted services' #13853

Merged
merged 5 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func resourceServiceBusNamespaceNetworkRuleSet() *pluginsdk.Resource {
},
},

"allow_trusted_services": {
dylanmorley marked this conversation as resolved.
Show resolved Hide resolved
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},

"network_rules": {
Type: pluginsdk.TypeSet,
Optional: true,
Expand Down Expand Up @@ -119,9 +125,10 @@ func resourceServiceBusNamespaceNetworkRuleSetCreateUpdate(d *pluginsdk.Resource

parameters := servicebus.NetworkRuleSet{
NetworkRuleSetProperties: &servicebus.NetworkRuleSetProperties{
DefaultAction: servicebus.DefaultAction(d.Get("default_action").(string)),
VirtualNetworkRules: expandServiceBusNamespaceVirtualNetworkRules(d.Get("network_rules").(*pluginsdk.Set).List()),
IPRules: expandServiceBusNamespaceIPRules(d.Get("ip_rules").(*pluginsdk.Set).List()),
DefaultAction: servicebus.DefaultAction(d.Get("default_action").(string)),
VirtualNetworkRules: expandServiceBusNamespaceVirtualNetworkRules(d.Get("network_rules").(*pluginsdk.Set).List()),
IPRules: expandServiceBusNamespaceIPRules(d.Get("ip_rules").(*pluginsdk.Set).List()),
TrustedServiceAccessEnabled: utils.Bool(d.Get("allow_trusted_services").(bool)),
},
}

Expand Down Expand Up @@ -158,6 +165,7 @@ func resourceServiceBusNamespaceNetworkRuleSetRead(d *pluginsdk.ResourceData, me

if props := resp.NetworkRuleSetProperties; props != nil {
d.Set("default_action", string(props.DefaultAction))
d.Set("allow_trusted_services", props.TrustedServiceAccessEnabled)

if err := d.Set("network_rules", pluginsdk.NewSet(networkRuleHash, flattenServiceBusNamespaceVirtualNetworkRules(props.VirtualNetworkRules))); err != nil {
return fmt.Errorf("failed to set `network_rules`: %+v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestAccServiceBusNamespaceNetworkRule_complete(t *testing.T) {
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("allow_trusted_services").HasValue("true"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -130,7 +131,8 @@ resource "azurerm_servicebus_namespace_network_rule_set" "test" {
namespace_name = azurerm_servicebus_namespace.test.name
resource_group_name = azurerm_resource_group.test.name

default_action = "Deny"
default_action = "Deny"
allow_trusted_services = true

network_rules {
subnet_id = azurerm_subnet.test.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ The following arguments are supported:

* `default_action` - (Optional) Specifies the default action for the ServiceBus Namespace Network Rule Set. Possible values are `Allow` and `Deny`. Defaults to `Deny`.


* `allow_trusted_services` - (Optional) If True, then Azure Services that are known and trusted for this resource type are allowed to bypass firewall configuration. See [Trusted Microsoft Services](https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/service-bus-messaging/includes/service-bus-trusted-services.md)

* `ip_rules` - (Optional) One or more IP Addresses, or CIDR Blocks which should be able to access the ServiceBus Namespace.

* `network_rules` - (Optional) One or more `network_rules` blocks as defined below.
Expand Down