Skip to content

Commit

Permalink
Added a parameters for LoadBalancer resource (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
coderGo93 authored Mar 17, 2022
1 parent 2677ab9 commit 942f90d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
23 changes: 20 additions & 3 deletions internal/services/loadbalancer/loadbalancer_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/loadbalancer.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down

0 comments on commit 942f90d

Please sign in to comment.