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

azurerm_route_server - Add support for hub_routing_preference property #28363

Merged
merged 14 commits into from
Feb 6, 2025
Merged
17 changes: 17 additions & 0 deletions internal/services/network/route_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ func resourceRouteServer() *pluginsdk.Resource {
Default: false,
},

"hub_routing_preference": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(virtualwans.HubRoutingPreferenceExpressRoute),
ValidateFunc: validation.StringInSlice([]string{
string(virtualwans.HubRoutingPreferenceASPath),
string(virtualwans.HubRoutingPreferenceExpressRoute),
string(virtualwans.HubRoutingPreferenceVpnGateway),
}, false),
},

"virtual_router_ips": {
Type: pluginsdk.TypeSet,
Computed: true,
Expand Down Expand Up @@ -132,6 +143,7 @@ func resourceRouteServerCreate(d *pluginsdk.ResourceData, meta interface{}) erro
Properties: &virtualwans.VirtualHubProperties{
Sku: pointer.To(d.Get("sku").(string)),
AllowBranchToBranchTraffic: pointer.To(d.Get("branch_to_branch_traffic_enabled").(bool)),
HubRoutingPreference: pointer.To(virtualwans.HubRoutingPreference(d.Get("hub_routing_preference").(string))),
},
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}
Expand Down Expand Up @@ -209,6 +221,10 @@ func resourceRouteServerUpdate(d *pluginsdk.ResourceData, meta interface{}) erro
payload.Properties.AllowBranchToBranchTraffic = pointer.To(d.Get("branch_to_branch_traffic_enabled").(bool))
}

if d.HasChange("hub_routing_preference") {
payload.Properties.HubRoutingPreference = pointer.To(virtualwans.HubRoutingPreference(d.Get("hub_routing_preference").(string)))
}

if d.HasChange("tags") {
payload.Tags = tags.Expand(d.Get("tags").(map[string]interface{}))
}
Expand Down Expand Up @@ -272,6 +288,7 @@ func resourceRouteServerRead(d *pluginsdk.ResourceData, meta interface{}) error
if props.AllowBranchToBranchTraffic != nil {
d.Set("branch_to_branch_traffic_enabled", props.AllowBranchToBranchTraffic)
}
d.Set("hub_routing_preference", pointer.From(props.HubRoutingPreference))
if props.VirtualRouterAsn != nil {
d.Set("virtual_router_asn", props.VirtualRouterAsn)
}
Expand Down
17 changes: 14 additions & 3 deletions internal/services/network/route_server_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func TestAccRouteServer_basic(t *testing.T) {
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r)),
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
Expand Down Expand Up @@ -71,13 +72,22 @@ func TestAccRouteServer_update(t *testing.T) {
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r)),
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r)),
check.That(data.ResourceName).ExistsInAzure(r),
),
bubbletroubles marked this conversation as resolved.
Show resolved Hide resolved
},
data.ImportStep(),
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
Expand Down Expand Up @@ -147,6 +157,7 @@ resource "azurerm_route_server" "test" {
public_ip_address_id = azurerm_public_ip.test.id
subnet_id = azurerm_subnet.test.id
branch_to_branch_traffic_enabled = true
hub_routing_preference = "VpnGateway"
}
`, r.template(data), data.RandomInteger)
}
Expand Down
15 changes: 9 additions & 6 deletions website/docs/r/route_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ resource "azurerm_route_server" "example" {
public_ip_address_id = azurerm_public_ip.example.id
subnet_id = azurerm_subnet.example.id
branch_to_branch_traffic_enabled = true
hub_routing_preference = "ASPath"
}
```

Expand All @@ -65,23 +66,25 @@ The following arguments are supported:

* `location` - (Required) Specifies the supported Azure location where the Route Server should exist. Changing this forces a new resource to be created.

* `subnet_id` - (Required) The ID of the Subnet that the Route Server will reside. Changing this forces a new resource to be created.

-> **NOTE:** Azure Route Server requires a dedicated subnet named RouteServerSubnet. The subnet size has to be at least /27 or short prefix (such as /26 or /25) and cannot be attached to any security group, otherwise, you'll receive an error message when deploying the Route Server
* `public_ip_address_id` - (Required) The ID of the Public IP Address. This option is required since September 1st 2021. Changing this forces a new resource to be created.

* `sku` - (Required) The SKU of the Route Server. The only possible value is `Standard`. Changing this forces a new resource to be created.

* `public_ip_address_id` - (Required) The ID of the Public IP Address. This option is required since September 1st 2021. Changing this forces a new resource to be created.
* `subnet_id` - (Required) The ID of the Subnet that the Route Server will reside. Changing this forces a new resource to be created.
bubbletroubles marked this conversation as resolved.
Show resolved Hide resolved

-> **NOTE:** Azure Route Server requires a dedicated subnet named RouteServerSubnet. The subnet size has to be at least /27 or short prefix (such as /26 or /25) and cannot be attached to any security group, otherwise, you'll receive an error message when deploying the Route Server.

* `branch_to_branch_traffic_enabled` - (Optional) Whether to enable route exchange between Azure Route Server and the gateway(s).

* `branch_to_branch_traffic_enabled` - (Optional) Whether to enable route exchange between Azure Route Server and the gateway(s)
* `hub_routing_preference` - (Optional) The hub routing preference. Valid values are `ASPath`, `ExpressRoute` or `VpnGateway`. Defaults to `ExpressRoute`.

* `tags` - (Optional) A mapping of tags to assign to the resource.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

* `id` - The ID of the Route Server .
* `id` - The ID of the Route Server.

## Timeouts

Expand Down
Loading