Skip to content

azurerm_virtual_hub - support for new property allow_branch_to_branch_traffic #29453

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 14 additions & 2 deletions internal/services/network/virtual_hub_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func resourceVirtualHub() *pluginsdk.Resource {
ValidateFunc: validate.CIDR,
},

"allow_branch_to_branch_traffic": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},

"sku": {
Type: pluginsdk.TypeString,
Optional: true,
Expand Down Expand Up @@ -173,8 +179,9 @@ func resourceVirtualHubCreate(d *pluginsdk.ResourceData, meta interface{}) error
parameters := virtualwans.VirtualHub{
Location: pointer.To(location.Normalize(d.Get("location").(string))),
Properties: &virtualwans.VirtualHubProperties{
RouteTable: expandVirtualHubRoute(d.Get("route").(*pluginsdk.Set).List()),
HubRoutingPreference: pointer.To(virtualwans.HubRoutingPreference(d.Get("hub_routing_preference").(string))),
AllowBranchToBranchTraffic: pointer.To(d.Get("allow_branch_to_branch_traffic").(bool)),
RouteTable: expandVirtualHubRoute(d.Get("route").(*pluginsdk.Set).List()),
HubRoutingPreference: pointer.To(virtualwans.HubRoutingPreference(d.Get("hub_routing_preference").(string))),
},
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}
Expand Down Expand Up @@ -258,6 +265,10 @@ func resourceVirtualHubUpdate(d *pluginsdk.ResourceData, meta interface{}) error
return fmt.Errorf("retrieving %s: `properties` was nil", *id)
}

if d.HasChange("allow_branch_to_branch_traffic") {
payload.Properties.AllowBranchToBranchTraffic = pointer.To(d.Get("allow_branch_to_branch_traffic").(bool))
}

if d.HasChange("route") {
payload.Properties.RouteTable = expandVirtualHubRoute(d.Get("route").(*pluginsdk.Set).List())
}
Expand Down Expand Up @@ -336,6 +347,7 @@ func resourceVirtualHubRead(d *pluginsdk.ResourceData, meta interface{}) error {
d.Set("location", location.NormalizeNilable(model.Location))
if props := model.Properties; props != nil {
d.Set("address_prefix", props.AddressPrefix)
d.Set("allow_branch_to_branch_traffic", pointer.From(props.AllowBranchToBranchTraffic))
d.Set("sku", props.Sku)

if err := d.Set("route", flattenVirtualHubRoute(props.RouteTable)); err != nil {
Expand Down
22 changes: 12 additions & 10 deletions internal/services/network/virtual_hub_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,12 @@ func (r VirtualHubResource) route(data acceptance.TestData) string {
%s

resource "azurerm_virtual_hub" "test" {
name = "acctestVHUB-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
virtual_wan_id = azurerm_virtual_wan.test.id
address_prefix = "10.0.1.0/24"
name = "acctestVHUB-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
virtual_wan_id = azurerm_virtual_wan.test.id
address_prefix = "10.0.1.0/24"
allow_branch_to_branch_traffic = true

route {
address_prefixes = ["172.0.1.0/24"]
Expand All @@ -189,11 +190,12 @@ func (r VirtualHubResource) routeUpdated(data acceptance.TestData) string {
%s

resource "azurerm_virtual_hub" "test" {
name = "acctestVHUB-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
virtual_wan_id = azurerm_virtual_wan.test.id
address_prefix = "10.0.1.0/24"
name = "acctestVHUB-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
virtual_wan_id = azurerm_virtual_wan.test.id
address_prefix = "10.0.1.0/24"
allow_branch_to_branch_traffic = false

route {
address_prefixes = ["172.0.1.0/24"]
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/virtual_hub.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ The following arguments are supported:

* `address_prefix` - (Optional) The Address Prefix which should be used for this Virtual Hub. Changing this forces a new resource to be created. [The address prefix subnet cannot be smaller than a `/24`. Azure recommends using a `/23`](https://docs.microsoft.com/azure/virtual-wan/virtual-wan-faq#what-is-the-recommended-hub-address-space-during-hub-creation).

* `allow_branch_to_branch_traffic` - (Optional) Boolean flag to specify whether branch to branch traffic is allowed. Defaults to `false`.

* `virtual_router_auto_scale_min_capacity` - (Optional) Minimum instance capacity for the scaling configuration of the Virtual Hub Router. Defaults to `2`.

---
Expand Down
Loading