Skip to content

Commit

Permalink
Feature: Loadbalancer Outbound Rule (#2912)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcharriere authored and katbyte committed Feb 21, 2019
1 parent ba48f04 commit 45294b8
Show file tree
Hide file tree
Showing 6 changed files with 979 additions and 0 deletions.
14 changes: 14 additions & 0 deletions azurerm/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ func findLoadBalancerRuleByName(lb *network.LoadBalancer, name string) (*network
return nil, -1, false
}

func findLoadBalancerOutboundRuleByName(lb *network.LoadBalancer, name string) (*network.OutboundRule, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.OutboundRules == nil {
return nil, -1, false
}

for i, or := range *lb.LoadBalancerPropertiesFormat.OutboundRules {
if or.Name != nil && *or.Name == name {
return &or, i, true
}
}

return nil, -1, false
}

func findLoadBalancerNatRuleByName(lb *network.LoadBalancer, name string) (*network.InboundNatRule, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.InboundNatRules == nil {
return nil, -1, false
Expand Down
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_lb_nat_pool": resourceArmLoadBalancerNatPool(),
"azurerm_lb_nat_rule": resourceArmLoadBalancerNatRule(),
"azurerm_lb_probe": resourceArmLoadBalancerProbe(),
"azurerm_lb_outbound_rule": resourceArmLoadBalancerOutboundRule(),
"azurerm_lb_rule": resourceArmLoadBalancerRule(),
"azurerm_lb": resourceArmLoadBalancer(),
"azurerm_local_network_gateway": resourceArmLocalNetworkGateway(),
Expand Down
19 changes: 19 additions & 0 deletions azurerm/resource_arm_loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ func resourceArmLoadBalancer() *schema.Resource {
Set: schema.HashString,
},

"outbound_rules": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validate.NoEmptyStrings,
},
Set: schema.HashString,
},

"zones": singleZonesSchema(),
},
},
Expand Down Expand Up @@ -371,6 +381,15 @@ func flattenLoadBalancerFrontendIpConfiguration(ipConfigs *[]network.FrontendIPC

}
ipConfig["inbound_nat_rules"] = schema.NewSet(schema.HashString, inboundNatRules)

outboundRules := make([]interface{}, 0)
if rules := props.OutboundRules; rules != nil {
for _, rule := range *rules {
outboundRules = append(outboundRules, *rule.ID)
}

}
ipConfig["outbound_rules"] = schema.NewSet(schema.HashString, outboundRules)
}

result = append(result, ipConfig)
Expand Down
Loading

0 comments on commit 45294b8

Please sign in to comment.