From ad7774ec1acceb628bf4813c2a87d98e11a6e899 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 17 Apr 2024 15:03:50 +0200 Subject: [PATCH] Add EnablePrivateLinkFastPath` as `private_link_fast_path_enabled` to Virtual Network Gateway Connection In relation to https://github.com/hashicorp/terraform-provider-azurerm/pull/25596 this is needed also on the Virtual Network Gateway Connection, for users who connect their Express Routes via VNGs. This option is only available, when the `VirtualNetworkGatewayConnectionType` is `ExpressRoute` and when `expressRouteGatewayBypass` is set, thus guarding for that. --- ...rtual_network_gateway_connection_data_source.go | 6 ++++++ .../virtual_network_gateway_connection_resource.go | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/internal/services/network/virtual_network_gateway_connection_data_source.go b/internal/services/network/virtual_network_gateway_connection_data_source.go index 6a61d34cd858..d8250346b482 100644 --- a/internal/services/network/virtual_network_gateway_connection_data_source.go +++ b/internal/services/network/virtual_network_gateway_connection_data_source.go @@ -119,6 +119,11 @@ func dataSourceVirtualNetworkGatewayConnection() *pluginsdk.Resource { Computed: true, }, + "private_link_fast_path_enabled": { + Type: pluginsdk.TypeBool, + Computed: true, + }, + "resource_guid": { Type: pluginsdk.TypeString, Computed: true, @@ -227,6 +232,7 @@ func dataSourceVirtualNetworkGatewayConnectionRead(d *pluginsdk.ResourceData, me d.Set("egress_bytes_transferred", gwc.EgressBytesTransferred) d.Set("use_policy_based_traffic_selectors", gwc.UsePolicyBasedTrafficSelectors) d.Set("express_route_gateway_bypass", gwc.ExpressRouteGatewayBypass) + d.Set("private_link_fast_path_enabled", gwc.EnablePrivateLinkFastPath) d.Set("type", string(gwc.ConnectionType)) d.Set("connection_protocol", string(gwc.ConnectionProtocol)) d.Set("routing_weight", gwc.RoutingWeight) diff --git a/internal/services/network/virtual_network_gateway_connection_resource.go b/internal/services/network/virtual_network_gateway_connection_resource.go index f10b3261ee0f..2141623cff8b 100644 --- a/internal/services/network/virtual_network_gateway_connection_resource.go +++ b/internal/services/network/virtual_network_gateway_connection_resource.go @@ -161,6 +161,12 @@ func resourceVirtualNetworkGatewayConnection() *pluginsdk.Resource { Computed: true, }, + "private_link_fast_path_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, + "connection_protocol": { Type: pluginsdk.TypeString, Optional: true, @@ -521,6 +527,10 @@ func resourceVirtualNetworkGatewayConnectionRead(d *pluginsdk.ResourceData, meta d.Set("express_route_gateway_bypass", conn.ExpressRouteGatewayBypass) } + if conn.EnablePrivateLinkFastPath != nil { + d.Set("private_link_fast_path_enabled", conn.EnablePrivateLinkFastPath) + } + if conn.IpsecPolicies != nil { ipsecPolicies := flattenVirtualNetworkGatewayConnectionIpsecPolicies(conn.IpsecPolicies) @@ -586,6 +596,7 @@ func getVirtualNetworkGatewayConnectionProperties(d *pluginsdk.ResourceData, vir ConnectionType: connectionType, ConnectionMode: connectionMode, EnableBgp: utils.Bool(d.Get("enable_bgp").(bool)), + EnablePrivateLinkFastPath: utils.Bool(d.Get("private_link_fast_path_enabled").(bool)), ExpressRouteGatewayBypass: utils.Bool(d.Get("express_route_gateway_bypass").(bool)), UsePolicyBasedTrafficSelectors: utils.Bool(d.Get("use_policy_based_traffic_selectors").(bool)), } @@ -699,6 +710,9 @@ func getVirtualNetworkGatewayConnectionProperties(d *pluginsdk.ResourceData, vir if props.Peer == nil || props.Peer.ID == nil { return nil, fmt.Errorf("`express_route_circuit_id` must be specified when `type` is set to `ExpressRoute`") } + if d.Get("private_link_fast_path_enabled").(bool) && !d.Get("express_route_gateway_bypass_enabled").(bool) { + return nil, fmt.Errorf("`express_route_gateway_bypass_enabled` must be enabled when `private_link_fast_path_enabled` is set to `true`") + } } if props.ConnectionType == network.VirtualNetworkGatewayConnectionTypeIPsec {