From e30eaacd57751eb3eecd745970eb8fd955404b70 Mon Sep 17 00:00:00 2001 From: Neil Ye Date: Fri, 12 Jul 2024 21:18:04 +0800 Subject: [PATCH] `azurerm_lb_rule` - remove `Computed` from `idle_timeout_in_minutes`, `load_distribution` and `probe_id` (#26616) * azurerm_lb_rule - remove Computed from idle_timeout_in_minutes, load_distribution and probe_id * update schema * sort pkgs --- .../services/loadbalancer/rule_resource.go | 25 ++++++++++++++++--- website/docs/r/lb_rule.html.markdown | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/internal/services/loadbalancer/rule_resource.go b/internal/services/loadbalancer/rule_resource.go index 1ae1e82215fd..856e2dea396e 100644 --- a/internal/services/loadbalancer/rule_resource.go +++ b/internal/services/loadbalancer/rule_resource.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/helpers/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" loadBalancerValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/loadbalancer/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -326,7 +327,7 @@ func expandAzureRmLoadBalancerRule(d *pluginsdk.ResourceData, lb *loadbalancers. } func resourceArmLoadBalancerRuleSchema() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{ + resource := map[string]*pluginsdk.Schema{ "name": { Type: pluginsdk.TypeString, Required: true, @@ -389,7 +390,6 @@ func resourceArmLoadBalancerRuleSchema() map[string]*pluginsdk.Schema { "probe_id": { Type: pluginsdk.TypeString, Optional: true, - Computed: true, }, // TODO 4.0: change this from enable_* to *_enabled @@ -414,14 +414,31 @@ func resourceArmLoadBalancerRuleSchema() map[string]*pluginsdk.Schema { "idle_timeout_in_minutes": { Type: pluginsdk.TypeInt, Optional: true, - Computed: true, + Default: 4, ValidateFunc: validation.IntBetween(4, 100), }, "load_distribution": { Type: pluginsdk.TypeString, Optional: true, - Computed: true, + Default: string(loadbalancers.LoadDistributionDefault), }, } + + if !features.FourPointOhBeta() { + resource["idle_timeout_in_minutes"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntBetween(4, 100), + } + + resource["load_distribution"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + } + } + + return resource } diff --git a/website/docs/r/lb_rule.html.markdown b/website/docs/r/lb_rule.html.markdown index 11ba8132ffdf..60a9ca10869e 100644 --- a/website/docs/r/lb_rule.html.markdown +++ b/website/docs/r/lb_rule.html.markdown @@ -65,7 +65,7 @@ The following arguments are supported: * `probe_id` - (Optional) A reference to a Probe used by this Load Balancing Rule. * `enable_floating_ip` - (Optional) Are the Floating IPs enabled for this Load Balancer Rule? A "floating” IP is reassigned to a secondary server in case the primary server fails. Required to configure a SQL AlwaysOn Availability Group. Defaults to `false`. * `idle_timeout_in_minutes` - (Optional) Specifies the idle timeout in minutes for TCP connections. Valid values are between `4` and `100` minutes. Defaults to `4` minutes. -* `load_distribution` - (Optional) Specifies the load balancing distribution type to be used by the Load Balancer. Possible values are: `Default` – The load balancer is configured to use a 5 tuple hash to map traffic to available servers. `SourceIP` – The load balancer is configured to use a 2 tuple hash to map traffic to available servers. `SourceIPProtocol` – The load balancer is configured to use a 3 tuple hash to map traffic to available servers. Also known as Session Persistence, where in the Azure portal the options are called `None`, `Client IP` and `Client IP and Protocol` respectively. +* `load_distribution` - (Optional) Specifies the load balancing distribution type to be used by the Load Balancer. Possible values are: `Default` – The load balancer is configured to use a 5 tuple hash to map traffic to available servers. `SourceIP` – The load balancer is configured to use a 2 tuple hash to map traffic to available servers. `SourceIPProtocol` – The load balancer is configured to use a 3 tuple hash to map traffic to available servers. Also known as Session Persistence, where in the Azure portal the options are called `None`, `Client IP` and `Client IP and Protocol` respectively. Defaults to `Default`. * `disable_outbound_snat` - (Optional) Is snat enabled for this Load Balancer Rule? Default `false`. * `enable_tcp_reset` - (Optional) Is TCP Reset enabled for this Load Balancer Rule?