Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resources: azurerm_network_interface_(backend_address_pool|nat_rule)_association #2079

Merged
merged 8 commits into from
Oct 16, 2018
42 changes: 42 additions & 0 deletions azurerm/helpers/azure/network_interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package azure

import "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"

func FindNetworkInterfaceIPConfiguration(input *[]network.InterfaceIPConfiguration, name string) *network.InterfaceIPConfiguration {
if input == nil {
return nil
}

for _, v := range *input {
if v.Name == nil {
continue
}

if *v.Name == name {
return &v
}
}

return nil
}

func UpdateNetworkInterfaceIPConfiguration(config network.InterfaceIPConfiguration, configs *[]network.InterfaceIPConfiguration) *[]network.InterfaceIPConfiguration {
output := make([]network.InterfaceIPConfiguration, 0)
if configs == nil {
return &output
}

for _, v := range *configs {
if v.Name == nil {
continue
}

if *v.Name != *config.Name {
output = append(output, v)
} else {
output = append(output, config)
}
}

return &output
}
331 changes: 167 additions & 164 deletions azurerm/provider.go

Large diffs are not rendered by default.

29 changes: 20 additions & 9 deletions azurerm/resource_arm_network_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

var networkInterfaceResourceName = "azurerm_network_interface"

func resourceArmNetworkInterface() *schema.Resource {
return &schema.Resource{
Create: resourceArmNetworkInterfaceCreateUpdate,
Expand Down Expand Up @@ -97,9 +99,10 @@ func resourceArmNetworkInterface() *schema.Resource {
},

"application_gateway_backend_address_pools_ids": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Type: schema.TypeSet,
Optional: true,
Computed: true,
Deprecated: "This field has been deprecated in favour of the `azurerm_network_interface_application_gateway_backend_address_pool_association` resource.",
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: azure.ValidateResourceID,
Expand All @@ -108,9 +111,10 @@ func resourceArmNetworkInterface() *schema.Resource {
},

"load_balancer_backend_address_pools_ids": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Type: schema.TypeSet,
Optional: true,
Computed: true,
Deprecated: "This field has been deprecated in favour of the `azurerm_network_interface_backend_address_pool_association` resource.",
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: azure.ValidateResourceID,
Expand All @@ -119,9 +123,10 @@ func resourceArmNetworkInterface() *schema.Resource {
},

"load_balancer_inbound_nat_rules_ids": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Type: schema.TypeSet,
Optional: true,
Computed: true,
Deprecated: "This field has been deprecated in favour of the `azurerm_network_interface_nat_rule_association` resource.",
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: azure.ValidateResourceID,
Expand Down Expand Up @@ -241,6 +246,9 @@ func resourceArmNetworkInterfaceCreateUpdate(d *schema.ResourceData, meta interf
EnableAcceleratedNetworking: &enableAcceleratedNetworking,
}

azureRMLockByName(name, networkInterfaceResourceName)
defer azureRMUnlockByName(name, networkInterfaceResourceName)

if v, ok := d.GetOk("network_security_group_id"); ok {
nsgId := v.(string)
properties.NetworkSecurityGroup = &network.SecurityGroup{
Expand Down Expand Up @@ -430,6 +438,9 @@ func resourceArmNetworkInterfaceDelete(d *schema.ResourceData, meta interface{})
resGroup := id.ResourceGroup
name := id.Path["networkInterfaces"]

azureRMLockByName(name, networkInterfaceResourceName)
defer azureRMUnlockByName(name, networkInterfaceResourceName)

if v, ok := d.GetOk("network_security_group_id"); ok {
networkSecurityGroupId := v.(string)
networkSecurityGroupName, err := parseNetworkSecurityGroupName(networkSecurityGroupId)
Expand Down
Loading