From 942f90d8c5a965e93f6a335375dc14f7e9081c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20L=C3=B3pez?= Date: Thu, 17 Mar 2022 00:41:35 -0700 Subject: [PATCH] Added a parameters for LoadBalancer resource (#152) --- .../loadbalancer/loadbalancer_resource.go | 23 ++++++++++++++++--- .../loadbalancer_resource_test.go | 1 + website/docs/r/loadbalancer.html.markdown | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/internal/services/loadbalancer/loadbalancer_resource.go b/internal/services/loadbalancer/loadbalancer_resource.go index adb22e03f..6c1dec20d 100644 --- a/internal/services/loadbalancer/loadbalancer_resource.go +++ b/internal/services/loadbalancer/loadbalancer_resource.go @@ -53,6 +53,16 @@ func loadBalancer() *pluginsdk.Resource { "resource_group_name": commonschema.ResourceGroupName(), + "sku": { + Type: pluginsdk.TypeString, + Optional: true, + Default: string(network.LoadBalancerSkuNameBasic), + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(network.LoadBalancerSkuNameBasic), + }, false), + }, + "frontend_ip_configuration": { Type: pluginsdk.TypeList, Optional: true, @@ -192,9 +202,12 @@ func loadBalancerCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error } loadBalancer := network.LoadBalancer{ - Name: pointer.FromString(id.Name), - Location: pointer.FromString(location.Normalize(d.Get("location").(string))), - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + Name: pointer.FromString(id.Name), + Location: pointer.FromString(location.Normalize(d.Get("location").(string))), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + Sku: &network.LoadBalancerSku{ + Name: network.LoadBalancerSkuName(d.Get("sku").(string)), + }, LoadBalancerPropertiesFormat: &properties, } @@ -235,6 +248,10 @@ func loadBalancerRead(d *pluginsdk.ResourceData, meta interface{}) error { d.Set("resource_group_name", id.ResourceGroup) d.Set("location", location.NormalizeNilable(resp.Location)) + if sku := resp.Sku; sku != nil { + d.Set("sku", string(sku.Name)) + } + if props := resp.LoadBalancerPropertiesFormat; props != nil { if feipConfigs := props.FrontendIPConfigurations; feipConfigs != nil { if err := d.Set("frontend_ip_configuration", flattenLoadBalancerFrontendIpConfiguration(feipConfigs)); err != nil { diff --git a/internal/services/loadbalancer/loadbalancer_resource_test.go b/internal/services/loadbalancer/loadbalancer_resource_test.go index 29ad44140..d410d3923 100644 --- a/internal/services/loadbalancer/loadbalancer_resource_test.go +++ b/internal/services/loadbalancer/loadbalancer_resource_test.go @@ -355,6 +355,7 @@ resource "azurestack_lb" "test" { name = "acctestlb-%d" resource_group_name = azurestack_resource_group.test.name location = azurestack_resource_group.test.location + sku = "Basic" frontend_ip_configuration { name = "Internal" diff --git a/website/docs/r/loadbalancer.html.markdown b/website/docs/r/loadbalancer.html.markdown index f469d21d1..c2a1b09dc 100644 --- a/website/docs/r/loadbalancer.html.markdown +++ b/website/docs/r/loadbalancer.html.markdown @@ -45,6 +45,7 @@ The following arguments are supported: * `resource_group_name` - (Required) The name of the resource group in which to create the LoadBalancer. * `location` - (Required) Specifies the supported Azure location where the resource exists. * `frontend_ip_configuration` - (Optional) A frontend ip configuration block as documented below. +* `sku` - (Optional) The SKU of the Azure Load Balancer. Accepted values are `Basic` and `Standard`. Defaults to `Basic`. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -64,6 +65,7 @@ The following attributes are exported: * `id` - The LoadBalancer ID. * `private_ip_address` - The first private IP address assigned to the load balancer in `frontend_ip_configuration` blocks, if any. * `private_ip_addresses` - The list of private IP address assigned to the load balancer in `frontend_ip_configuration` blocks, if any. +* `outbound_rules_ids` - The list of IDs outbound rules that use this frontend IP. ## Import