From 701f5b1c1dacc96d46a1d926eeaeb94772ecc5b6 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Mon, 5 Aug 2024 16:41:07 +0800 Subject: [PATCH 1/3] remove private_link_fast_path_enabled default vaule --- .../express_route_connection_resource.go | 26 ++++++++++++------- .../express_route_connection_resource_test.go | 2 -- .../r/express_route_connection.html.markdown | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/internal/services/network/express_route_connection_resource.go b/internal/services/network/express_route_connection_resource.go index f596e3e6de71..cba12c3e6e86 100644 --- a/internal/services/network/express_route_connection_resource.go +++ b/internal/services/network/express_route_connection_resource.go @@ -78,7 +78,6 @@ func resourceExpressRouteConnection() *pluginsdk.Resource { "private_link_fast_path_enabled": { Type: pluginsdk.TypeBool, Optional: true, - Default: false, }, "express_route_gateway_bypass_enabled": { @@ -183,10 +182,6 @@ func resourceExpressRouteConnectionCreate(d *pluginsdk.ResourceData, meta interf return tf.ImportAsExistsError("azurerm_express_route_connection", id.ID()) } - if d.Get("private_link_fast_path_enabled").(bool) && !d.Get("express_route_gateway_bypass_enabled").(bool) { - return fmt.Errorf("`express_route_gateway_bypass_enabled` must be enabled when `private_link_fast_path_enabled` is set to `true`") - } - parameters := expressrouteconnections.ExpressRouteConnection{ Name: id.ExpressRouteConnectionName, Properties: &expressrouteconnections.ExpressRouteConnectionProperties{ @@ -197,10 +192,17 @@ func resourceExpressRouteConnectionCreate(d *pluginsdk.ResourceData, meta interf RoutingConfiguration: expandExpressRouteConnectionRouting(d.Get("routing").([]interface{})), RoutingWeight: pointer.To(int64(d.Get("routing_weight").(int))), ExpressRouteGatewayBypass: pointer.To(d.Get("express_route_gateway_bypass_enabled").(bool)), - EnablePrivateLinkFastPath: pointer.To(d.Get("private_link_fast_path_enabled").(bool)), }, } + privateLinkFatPath := d.GetRawConfig().AsValueMap()["private_link_fast_path_enabled"] + if !privateLinkFatPath.IsNull() { + if d.Get("private_link_fast_path_enabled").(bool) && !d.Get("express_route_gateway_bypass_enabled").(bool) { + return fmt.Errorf("`express_route_gateway_bypass_enabled` must be enabled when `private_link_fast_path_enabled` is set to `true`") + } + parameters.Properties.EnablePrivateLinkFastPath = pointer.To(d.Get("private_link_fast_path_enabled").(bool)) + } + if v, ok := d.GetOk("authorization_key"); ok { parameters.Properties.AuthorizationKey = pointer.To(v.(string)) } @@ -280,9 +282,6 @@ func resourceExpressRouteConnectionUpdate(d *pluginsdk.ResourceData, meta interf return err } - if d.Get("private_link_fast_path_enabled").(bool) && !d.Get("express_route_gateway_bypass_enabled").(bool) { - return fmt.Errorf("`express_route_gateway_bypass_enabled` must be enabled when `private_link_fast_path_enabled` is set to `true`") - } parameters := expressrouteconnections.ExpressRouteConnection{ Name: id.ExpressRouteConnectionName, Properties: &expressrouteconnections.ExpressRouteConnectionProperties{ @@ -293,10 +292,17 @@ func resourceExpressRouteConnectionUpdate(d *pluginsdk.ResourceData, meta interf RoutingConfiguration: expandExpressRouteConnectionRouting(d.Get("routing").([]interface{})), RoutingWeight: pointer.To(int64(d.Get("routing_weight").(int))), ExpressRouteGatewayBypass: pointer.To(d.Get("express_route_gateway_bypass_enabled").(bool)), - EnablePrivateLinkFastPath: pointer.To(d.Get("private_link_fast_path_enabled").(bool)), }, } + privateLinkFatPath := d.GetRawConfig().AsValueMap()["private_link_fast_path_enabled"] + if !privateLinkFatPath.IsNull() { + if d.Get("private_link_fast_path_enabled").(bool) && !d.Get("express_route_gateway_bypass_enabled").(bool) { + return fmt.Errorf("`express_route_gateway_bypass_enabled` must be enabled when `private_link_fast_path_enabled` is set to `true`") + } + parameters.Properties.EnablePrivateLinkFastPath = pointer.To(d.Get("private_link_fast_path_enabled").(bool)) + } + if v, ok := d.GetOk("authorization_key"); ok { parameters.Properties.AuthorizationKey = pointer.To(v.(string)) } diff --git a/internal/services/network/express_route_connection_resource_test.go b/internal/services/network/express_route_connection_resource_test.go index 2f35bdac4595..14e06318f805 100644 --- a/internal/services/network/express_route_connection_resource_test.go +++ b/internal/services/network/express_route_connection_resource_test.go @@ -148,7 +148,6 @@ resource "azurerm_express_route_connection" "test" { routing_weight = 2 authorization_key = "90f8db47-e25b-4b65-a68b-7743ced2a16b" enable_internet_security = true - private_link_fast_path_enabled = true express_route_gateway_bypass_enabled = true routing { @@ -220,7 +219,6 @@ resource "azurerm_express_route_connection" "test" { routing_weight = 2 authorization_key = "90f8db47-e25b-4b65-a68b-7743ced2a16b" enable_internet_security = true - private_link_fast_path_enabled = true express_route_gateway_bypass_enabled = true routing { diff --git a/website/docs/r/express_route_connection.html.markdown b/website/docs/r/express_route_connection.html.markdown index d85a0b67d538..280624b60237 100644 --- a/website/docs/r/express_route_connection.html.markdown +++ b/website/docs/r/express_route_connection.html.markdown @@ -98,7 +98,7 @@ The following arguments are supported: * `express_route_gateway_bypass_enabled` - (Optional) Specified whether Fast Path is enabled for Virtual Wan Firewall Hub. Defaults to `false`. -* `private_link_fast_path_enabled` - (Optional) Bypass the Express Route gateway when accessing private-links. When enabled `express_route_gateway_bypass_enabled` must be set to `true`. Defaults to `false`. +* `private_link_fast_path_enabled` - (Optional) Bypass the Express Route gateway when accessing private-links. When enabled `express_route_gateway_bypass_enabled` must be set to `true`. * `routing` - (Optional) A `routing` block as defined below. From b99bd0105a0699e03bbbdea553f2851bac4be0a2 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Mon, 12 Aug 2024 10:21:06 +0800 Subject: [PATCH 2/3] increase the timeout to ensure created/updated in time --- internal/services/network/route_map_resource.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/network/route_map_resource.go b/internal/services/network/route_map_resource.go index 529c37f1ffff..12e07f6caa85 100644 --- a/internal/services/network/route_map_resource.go +++ b/internal/services/network/route_map_resource.go @@ -216,7 +216,7 @@ func (r RouteMapResource) Attributes() map[string]*pluginsdk.Schema { func (r RouteMapResource) Create() sdk.ResourceFunc { return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, + Timeout: 60 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { var model RouteMapModel if err := metadata.Decode(&model); err != nil { @@ -256,7 +256,7 @@ func (r RouteMapResource) Create() sdk.ResourceFunc { func (r RouteMapResource) Update() sdk.ResourceFunc { return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, + Timeout: 60 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.Network.VirtualWANs @@ -333,7 +333,7 @@ func (r RouteMapResource) Read() sdk.ResourceFunc { func (r RouteMapResource) Delete() sdk.ResourceFunc { return sdk.ResourceFunc{ - Timeout: 30 * time.Minute, + Timeout: 60 * time.Minute, Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { client := metadata.Client.Network.VirtualWANs From 56b7a977e2f633d9db2a4495d5250b75228c395a Mon Sep 17 00:00:00 2001 From: xu Date: Wed, 14 Aug 2024 10:35:05 +0800 Subject: [PATCH 3/3] fix typo --- .../services/network/express_route_connection_resource.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/network/express_route_connection_resource.go b/internal/services/network/express_route_connection_resource.go index cba12c3e6e86..04a1c1c88a96 100644 --- a/internal/services/network/express_route_connection_resource.go +++ b/internal/services/network/express_route_connection_resource.go @@ -195,8 +195,8 @@ func resourceExpressRouteConnectionCreate(d *pluginsdk.ResourceData, meta interf }, } - privateLinkFatPath := d.GetRawConfig().AsValueMap()["private_link_fast_path_enabled"] - if !privateLinkFatPath.IsNull() { + privateLinkFastPath := d.GetRawConfig().AsValueMap()["private_link_fast_path_enabled"] + if !privateLinkFastPath.IsNull() { if d.Get("private_link_fast_path_enabled").(bool) && !d.Get("express_route_gateway_bypass_enabled").(bool) { return fmt.Errorf("`express_route_gateway_bypass_enabled` must be enabled when `private_link_fast_path_enabled` is set to `true`") } @@ -295,8 +295,8 @@ func resourceExpressRouteConnectionUpdate(d *pluginsdk.ResourceData, meta interf }, } - privateLinkFatPath := d.GetRawConfig().AsValueMap()["private_link_fast_path_enabled"] - if !privateLinkFatPath.IsNull() { + privateLinkFastPath := d.GetRawConfig().AsValueMap()["private_link_fast_path_enabled"] + if !privateLinkFastPath.IsNull() { if d.Get("private_link_fast_path_enabled").(bool) && !d.Get("express_route_gateway_bypass_enabled").(bool) { return fmt.Errorf("`express_route_gateway_bypass_enabled` must be enabled when `private_link_fast_path_enabled` is set to `true`") }