From 5b634bd11a7aa159c57eab6992e84f0583bca101 Mon Sep 17 00:00:00 2001 From: Chris Cuthbertson Date: Wed, 19 Dec 2018 10:19:03 -0700 Subject: [PATCH 1/7] Implement private_ip_address_version for network interfaces. --- azurerm/resource_arm_network_interface.go | 88 +++++++++++++------ .../resource_arm_network_interface_test.go | 70 +++++++++++++++ .../docs/r/network_interface.html.markdown | 4 +- 3 files changed, 134 insertions(+), 28 deletions(-) diff --git a/azurerm/resource_arm_network_interface.go b/azurerm/resource_arm_network_interface.go index 8245fc088d8d..52c4329e1d24 100644 --- a/azurerm/resource_arm_network_interface.go +++ b/azurerm/resource_arm_network_interface.go @@ -71,7 +71,7 @@ func resourceArmNetworkInterface() *schema.Resource { "subnet_id": { Type: schema.TypeString, - Required: true, + Optional: true, DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: azure.ValidateResourceID, }, @@ -81,6 +81,17 @@ func resourceArmNetworkInterface() *schema.Resource { Optional: true, }, + "private_ip_address_version": { + Type: schema.TypeString, + Optional: true, + Default: string(network.IPv4), + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{ + string(network.IPv4), + string(network.IPv6), + }, true), + }, + "private_ip_address_allocation": { Type: schema.TypeString, Required: true, @@ -360,12 +371,16 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e if configs[0].InterfaceIPConfigurationPropertiesFormat != nil { privateIPAddress := configs[0].InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress d.Set("private_ip_address", *privateIPAddress) + privateIPAddressVersion := configs[0].InterfaceIPConfigurationPropertiesFormat.PrivateIPAddressVersion + d.Set("private_ip_address_version", string(privateIPAddressVersion)) } addresses := make([]interface{}, 0) for _, config := range configs { if config.InterfaceIPConfigurationPropertiesFormat != nil { - addresses = append(addresses, *config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress) + if config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAddressVersion == network.IPv4 { + addresses = append(addresses, *config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress) + } } } @@ -456,18 +471,20 @@ func resourceArmNetworkInterfaceDelete(d *schema.ResourceData, meta interface{}) data := configRaw.(map[string]interface{}) subnet_id := data["subnet_id"].(string) - subnetId, err2 := parseAzureResourceID(subnet_id) - if err2 != nil { - return err2 - } - subnetName := subnetId.Path["subnets"] - if !sliceContainsValue(subnetNamesToLock, subnetName) { - subnetNamesToLock = append(subnetNamesToLock, subnetName) - } + if subnet_id != "" { + subnetId, err2 := parseAzureResourceID(subnet_id) + if err2 != nil { + return err2 + } + subnetName := subnetId.Path["subnets"] + if !sliceContainsValue(subnetNamesToLock, subnetName) { + subnetNamesToLock = append(subnetNamesToLock, subnetName) + } - virtualNetworkName := subnetId.Path["virtualNetworks"] - if !sliceContainsValue(virtualNetworkNamesToLock, virtualNetworkName) { - virtualNetworkNamesToLock = append(virtualNetworkNamesToLock, virtualNetworkName) + virtualNetworkName := subnetId.Path["virtualNetworks"] + if !sliceContainsValue(virtualNetworkNamesToLock, virtualNetworkName) { + virtualNetworkNamesToLock = append(virtualNetworkNamesToLock, virtualNetworkName) + } } } @@ -497,13 +514,21 @@ func flattenNetworkInterfaceIPConfigurations(ipConfigs *[]network.InterfaceIPCon props := ipConfig.InterfaceIPConfigurationPropertiesFormat niIPConfig["name"] = *ipConfig.Name - niIPConfig["subnet_id"] = *props.Subnet.ID + + if props.Subnet != nil { + niIPConfig["subnet_id"] = *props.Subnet.ID + } + niIPConfig["private_ip_address_allocation"] = strings.ToLower(string(props.PrivateIPAllocationMethod)) if props.PrivateIPAllocationMethod == network.Static { niIPConfig["private_ip_address"] = *props.PrivateIPAddress } + if props.PrivateIPAddressVersion != "" { + niIPConfig["private_ip_address_version"] = props.PrivateIPAddressVersion + } + if props.PublicIPAddress != nil { niIPConfig["public_ip_address_id"] = *props.PublicIPAddress.ID } @@ -560,29 +585,38 @@ func expandAzureRmNetworkInterfaceIpConfigurations(d *schema.ResourceData) ([]ne subnet_id := data["subnet_id"].(string) private_ip_allocation_method := data["private_ip_address_allocation"].(string) + private_ip_address_version := network.IPVersion(data["private_ip_address_version"].(string)) allocationMethod := network.IPAllocationMethod(private_ip_allocation_method) properties := network.InterfaceIPConfigurationPropertiesFormat{ - Subnet: &network.Subnet{ - ID: &subnet_id, - }, PrivateIPAllocationMethod: allocationMethod, + PrivateIPAddressVersion: private_ip_address_version, } - subnetId, err := parseAzureResourceID(subnet_id) - if err != nil { - return []network.InterfaceIPConfiguration{}, nil, nil, err + if private_ip_address_version == network.IPv4 && subnet_id == "" { + return nil, nil, nil, fmt.Errorf("Required field `ip_configuration`, `subnet_id` must be specified when using IPv4.") } - subnetName := subnetId.Path["subnets"] - virtualNetworkName := subnetId.Path["virtualNetworks"] + if subnet_id != "" { + properties.Subnet = &network.Subnet{ + ID: &subnet_id, + } - if !sliceContainsValue(subnetNamesToLock, subnetName) { - subnetNamesToLock = append(subnetNamesToLock, subnetName) - } + subnetId, err := parseAzureResourceID(subnet_id) + if err != nil { + return []network.InterfaceIPConfiguration{}, nil, nil, err + } + + subnetName := subnetId.Path["subnets"] + virtualNetworkName := subnetId.Path["virtualNetworks"] - if !sliceContainsValue(virtualNetworkNamesToLock, virtualNetworkName) { - virtualNetworkNamesToLock = append(virtualNetworkNamesToLock, virtualNetworkName) + if !sliceContainsValue(subnetNamesToLock, subnetName) { + subnetNamesToLock = append(subnetNamesToLock, subnetName) + } + + if !sliceContainsValue(virtualNetworkNamesToLock, virtualNetworkName) { + virtualNetworkNamesToLock = append(virtualNetworkNamesToLock, virtualNetworkName) + } } if v := data["private_ip_address"].(string); v != "" { diff --git a/azurerm/resource_arm_network_interface_test.go b/azurerm/resource_arm_network_interface_test.go index b2b5ad29a5c5..279118d1d864 100644 --- a/azurerm/resource_arm_network_interface_test.go +++ b/azurerm/resource_arm_network_interface_test.go @@ -366,6 +366,26 @@ func TestAccAzureRMNetworkInterface_IPAddressesBug1286(t *testing.T) { }) } +func TestAccAzureRMNetworkInterface_IPAddressesFeature2543(t *testing.T) { + resourceName := "azurerm_network_interface.test" + rInt := acctest.RandInt() + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMNetworkInterface_withIPv6Addresses(rInt, testLocation()), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMNetworkInterfaceExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "ip_configuration.0.private_ip_address_version", "IPv4"), + resource.TestCheckResourceAttr(resourceName, "ip_configuration.1.private_ip_address_version", "IPv6"), + ), + }, + }, + }) +} + func TestAccAzureRMNetworkInterface_bug7986(t *testing.T) { rInt := acctest.RandInt() resource.ParallelTest(t, resource.TestCase{ @@ -912,6 +932,56 @@ resource "azurerm_network_interface" "test" { `, rInt, location, rInt, rInt, rInt) } +func testAccAzureRMNetworkInterface_withIPv6Addresses(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctest-rg-%d" + location = "%s" +} + +resource "azurerm_virtual_network" "test" { + name = "acctestvn-%d" + address_space = ["10.0.0.0/16"] + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_subnet" "test" { + name = "testsubnet" + resource_group_name = "${azurerm_resource_group.test.name}" + virtual_network_name = "${azurerm_virtual_network.test.name}" + address_prefix = "10.0.2.0/24" +} + +resource "azurerm_public_ip" "test" { + name = "test-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + public_ip_address_allocation = "static" + domain_name_label = "${azurerm_resource_group.test.name}" +} + +resource "azurerm_network_interface" "test" { + name = "acctestni-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + + ip_configuration { + name = "testconfiguration1" + subnet_id = "${azurerm_subnet.test.id}" + private_ip_address_allocation = "dynamic" + primary = true + } + + ip_configuration { + name = "testconfiguration2" + private_ip_address_version = "IPv6" + private_ip_address_allocation = "dynamic" + } +} +`, rInt, location, rInt, rInt, rInt) +} + func testAccAzureRMNetworkInterface_multipleLoadBalancers(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index d48fd1cc3d8b..fa4f9077b6a2 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -80,12 +80,14 @@ The `ip_configuration` block supports: * `name` - (Required) User-defined name of the IP. -* `subnet_id` - (Required) Reference to a subnet in which this NIC has been created. +* `subnet_id` - (Optional) Reference to a subnet in which this NIC has been created. Required when `private_ip_address_version` is IPv4. * `private_ip_address` - (Optional) Static IP Address. * `private_ip_address_allocation` - (Required) Defines how a private IP address is assigned. Options are Static or Dynamic. +* `private_ip_address_version` - (Optional) The IP Version to use, IPv6 or IPv4. Defaults to IPv4. + * `public_ip_address_id` - (Optional) Reference to a Public IP Address to associate with this NIC * `application_gateway_backend_address_pools_ids` - (Optional / **Deprecated**) List of Application Gateway Backend Address Pool IDs references to which this NIC belongs From 371365fb7e2bdfe3cf9c2a8a46344826e88a5be1 Mon Sep 17 00:00:00 2001 From: Chris Cuthbertson Date: Fri, 28 Dec 2018 18:04:00 -0700 Subject: [PATCH 2/7] Changes due to feedback. --- azurerm/resource_arm_network_interface.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_network_interface.go b/azurerm/resource_arm_network_interface.go index 52c4329e1d24..05f7dd0a17d0 100644 --- a/azurerm/resource_arm_network_interface.go +++ b/azurerm/resource_arm_network_interface.go @@ -89,7 +89,7 @@ func resourceArmNetworkInterface() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{ string(network.IPv4), string(network.IPv6), - }, true), + }, false), }, "private_ip_address_allocation": { @@ -515,7 +515,7 @@ func flattenNetworkInterfaceIPConfigurations(ipConfigs *[]network.InterfaceIPCon niIPConfig["name"] = *ipConfig.Name - if props.Subnet != nil { + if props.Subnet != nil && props.Subnet.ID != nil { niIPConfig["subnet_id"] = *props.Subnet.ID } @@ -526,7 +526,7 @@ func flattenNetworkInterfaceIPConfigurations(ipConfigs *[]network.InterfaceIPCon } if props.PrivateIPAddressVersion != "" { - niIPConfig["private_ip_address_version"] = props.PrivateIPAddressVersion + niIPConfig["private_ip_address_version"] = string(props.PrivateIPAddressVersion) } if props.PublicIPAddress != nil { @@ -594,7 +594,7 @@ func expandAzureRmNetworkInterfaceIpConfigurations(d *schema.ResourceData) ([]ne } if private_ip_address_version == network.IPv4 && subnet_id == "" { - return nil, nil, nil, fmt.Errorf("Required field `ip_configuration`, `subnet_id` must be specified when using IPv4.") + return nil, nil, nil, fmt.Errorf("A Subnet ID must be specified for an IPv4 Network Interface.") } if subnet_id != "" { From e3fab5a5359fd75f2b04229a57b3705a78b6d6cc Mon Sep 17 00:00:00 2001 From: Chris Cuthbertson Date: Thu, 3 Jan 2019 11:51:36 -0700 Subject: [PATCH 3/7] Nil checking and readability. --- azurerm/resource_arm_network_interface.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/azurerm/resource_arm_network_interface.go b/azurerm/resource_arm_network_interface.go index 05f7dd0a17d0..87f900a663bb 100644 --- a/azurerm/resource_arm_network_interface.go +++ b/azurerm/resource_arm_network_interface.go @@ -368,18 +368,18 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e if props.IPConfigurations != nil && len(*props.IPConfigurations) > 0 { configs := *props.IPConfigurations - if configs[0].InterfaceIPConfigurationPropertiesFormat != nil { - privateIPAddress := configs[0].InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress - d.Set("private_ip_address", *privateIPAddress) - privateIPAddressVersion := configs[0].InterfaceIPConfigurationPropertiesFormat.PrivateIPAddressVersion - d.Set("private_ip_address_version", string(privateIPAddressVersion)) + if ipProps := configs[0].InterfaceIPConfigurationPropertiesFormat; ipProps != nil { + if privateIPAddress := ipProps.PrivateIPAddress; privateIPAddress != nil { + d.Set("private_ip_address", *privateIPAddress) + } + d.Set("private_ip_address_version", string(ipProps.PrivateIPAddressVersion)) } addresses := make([]interface{}, 0) for _, config := range configs { - if config.InterfaceIPConfigurationPropertiesFormat != nil { - if config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAddressVersion == network.IPv4 { - addresses = append(addresses, *config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress) + if ipProps := config.InterfaceIPConfigurationPropertiesFormat; ipProps != nil { + if ipProps.PrivateIPAddressVersion == network.IPv4 && ipProps.PrivateIPAddress != nil { + addresses = append(addresses, *ipProps.PrivateIPAddress) } } } From a9841fea178f834aec0877e9716f007ecd3a9f3d Mon Sep 17 00:00:00 2001 From: Chris Cuthbertson Date: Sat, 5 Jan 2019 13:22:59 -0700 Subject: [PATCH 4/7] Add private IP address version to the schema. --- azurerm/resource_arm_network_interface.go | 16 +++++++++++----- azurerm/resource_arm_network_interface_test.go | 1 + website/docs/r/network_interface.html.markdown | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/azurerm/resource_arm_network_interface.go b/azurerm/resource_arm_network_interface.go index 87f900a663bb..93f3dbe6893f 100644 --- a/azurerm/resource_arm_network_interface.go +++ b/azurerm/resource_arm_network_interface.go @@ -226,6 +226,11 @@ func resourceArmNetworkInterface() *schema.Resource { Computed: true, }, + "private_ip_address_version": { + Type: schema.TypeString, + Computed: true, + }, + "private_ip_addresses": { Type: schema.TypeList, Computed: true, @@ -375,16 +380,17 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e d.Set("private_ip_address_version", string(ipProps.PrivateIPAddressVersion)) } - addresses := make([]interface{}, 0) + addressesIPv4 := make([]interface{}, 0) + for _, config := range configs { - if ipProps := config.InterfaceIPConfigurationPropertiesFormat; ipProps != nil { - if ipProps.PrivateIPAddressVersion == network.IPv4 && ipProps.PrivateIPAddress != nil { - addresses = append(addresses, *ipProps.PrivateIPAddress) + if ipProps := config.InterfaceIPConfigurationPropertiesFormat; ipProps != nil && ipProps.PrivateIPAddress != nil { + if ipProps.PrivateIPAddressVersion == network.IPv4 { + addressesIPv4 = append(addressesIPv4, *ipProps.PrivateIPAddress) } } } - if err := d.Set("private_ip_addresses", addresses); err != nil { + if err := d.Set("private_ip_addresses", addressesIPv4); err != nil { return err } } diff --git a/azurerm/resource_arm_network_interface_test.go b/azurerm/resource_arm_network_interface_test.go index 279118d1d864..7af0a09acd08 100644 --- a/azurerm/resource_arm_network_interface_test.go +++ b/azurerm/resource_arm_network_interface_test.go @@ -380,6 +380,7 @@ func TestAccAzureRMNetworkInterface_IPAddressesFeature2543(t *testing.T) { testCheckAzureRMNetworkInterfaceExists(resourceName), resource.TestCheckResourceAttr(resourceName, "ip_configuration.0.private_ip_address_version", "IPv4"), resource.TestCheckResourceAttr(resourceName, "ip_configuration.1.private_ip_address_version", "IPv6"), + resource.TestCheckResourceAttrSet(resourceName, "private_ip_address"), ), }, }, diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index fa4f9077b6a2..e451195853e3 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -112,7 +112,8 @@ The following attributes are exported: * `id` - The Virtual Network Interface ID. * `mac_address` - The media access control (MAC) address of the network interface. -* `private_ip_address` - The private ip address of the network interface. +* `private_ip_address` - The private IP address of the network interface. +* `private_ip_address_version` - The private IP address version. * `virtual_machine_id` - Reference to a VM with which this NIC has been associated. * `applied_dns_servers` - If the VM that uses this NIC is part of an Availability Set, then this list will have the union of all DNS servers from all NICs that are part of the Availability Set From b080c1950317f6f89fa45e44b2dc75574455de11 Mon Sep 17 00:00:00 2001 From: kt Date: Mon, 7 Jan 2019 02:29:42 -0800 Subject: [PATCH 5/7] removed private_ip_address_version from top level and removed some crash points --- azurerm/resource_arm_network_interface.go | 108 ++++++++---------- .../docs/r/network_interface.html.markdown | 4 +- 2 files changed, 51 insertions(+), 61 deletions(-) diff --git a/azurerm/resource_arm_network_interface.go b/azurerm/resource_arm_network_interface.go index 93f3dbe6893f..b20528a4b10e 100644 --- a/azurerm/resource_arm_network_interface.go +++ b/azurerm/resource_arm_network_interface.go @@ -221,15 +221,12 @@ func resourceArmNetworkInterface() *schema.Resource { Default: false, }, + // todo consider removing this one day as it is exposed in `private_ip_addresses.0` "private_ip_address": { Type: schema.TypeString, Computed: true, }, - "private_ip_address_version": { - Type: schema.TypeString, - Computed: true, - }, "private_ip_addresses": { Type: schema.TypeList, @@ -367,78 +364,71 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error making Read request on Azure Network Interface %q (Resource Group %q): %+v", name, resGroup, err) } - props := *resp.InterfacePropertiesFormat - - d.Set("mac_address", props.MacAddress) - if props.IPConfigurations != nil && len(*props.IPConfigurations) > 0 { - configs := *props.IPConfigurations - - if ipProps := configs[0].InterfaceIPConfigurationPropertiesFormat; ipProps != nil { - if privateIPAddress := ipProps.PrivateIPAddress; privateIPAddress != nil { - d.Set("private_ip_address", *privateIPAddress) - } - d.Set("private_ip_address_version", string(ipProps.PrivateIPAddressVersion)) - } - - addressesIPv4 := make([]interface{}, 0) + d.Set("name", resp.Name) + d.Set("resource_group_name", resGroup) + if location := resp.Location; location != nil { + d.Set("location", azureRMNormalizeLocation(*location)) + } - for _, config := range configs { - if ipProps := config.InterfaceIPConfigurationPropertiesFormat; ipProps != nil && ipProps.PrivateIPAddress != nil { - if ipProps.PrivateIPAddressVersion == network.IPv4 { - addressesIPv4 = append(addressesIPv4, *ipProps.PrivateIPAddress) + if props := resp.InterfacePropertiesFormat; props != nil { + + d.Set("mac_address", props.MacAddress) + addresses := make([]interface{}, 0) + if configs := props.IPConfigurations; configs != nil { + for i, config := range *props.IPConfigurations { + if ipProps := config.InterfaceIPConfigurationPropertiesFormat; ipProps != nil { + if v := ipProps.PrivateIPAddress; v != nil { + if i == 0 { + d.Set("private_ip_address", *v) + } + addresses = append(addresses, *v) + } } } } - - if err := d.Set("private_ip_addresses", addressesIPv4); err != nil { + if err := d.Set("private_ip_addresses", addresses); err != nil { return err } - } - if props.IPConfigurations != nil { - configs := flattenNetworkInterfaceIPConfigurations(props.IPConfigurations) - if err := d.Set("ip_configuration", configs); err != nil { - return fmt.Errorf("Error setting `ip_configuration`: %+v", err) + if props.IPConfigurations != nil { + configs := flattenNetworkInterfaceIPConfigurations(props.IPConfigurations) + if err := d.Set("ip_configuration", configs); err != nil { + return fmt.Errorf("Error setting `ip_configuration`: %+v", err) + } + } + + if vm := props.VirtualMachine; vm != nil { + d.Set("virtual_machine_id", vm.ID) } - } - if vm := props.VirtualMachine; vm != nil { - d.Set("virtual_machine_id", *vm.ID) - } + var appliedDNSServers []string + var dnsServers []string + if dnsSettings := props.DNSSettings; dnsSettings != nil { + if s := dnsSettings.AppliedDNSServers; s != nil { + appliedDNSServers = *s + } - var appliedDNSServers []string - var dnsServers []string - if dnsSettings := props.DNSSettings; dnsSettings != nil { - if s := dnsSettings.AppliedDNSServers; s != nil { - appliedDNSServers = *s - } + if s := dnsSettings.DNSServers; s != nil { + dnsServers = *s + } - if s := dnsSettings.DNSServers; s != nil { - dnsServers = *s + d.Set("internal_fqdn", dnsSettings.InternalFqdn) + d.Set("internal_dns_name_label", dnsSettings.InternalDNSNameLabel) } - d.Set("internal_fqdn", dnsSettings.InternalFqdn) - d.Set("internal_dns_name_label", dnsSettings.InternalDNSNameLabel) - } - - d.Set("applied_dns_servers", appliedDNSServers) - d.Set("dns_servers", dnsServers) + d.Set("applied_dns_servers", appliedDNSServers) + d.Set("dns_servers", dnsServers) - if nsg := props.NetworkSecurityGroup; nsg != nil { - d.Set("network_security_group_id", nsg.ID) - } else { - d.Set("network_security_group_id", "") - } + if nsg := props.NetworkSecurityGroup; nsg != nil { + d.Set("network_security_group_id", nsg.ID) + } else { + d.Set("network_security_group_id", "") + } - d.Set("name", resp.Name) - d.Set("resource_group_name", resGroup) - if location := resp.Location; location != nil { - d.Set("location", azureRMNormalizeLocation(*location)) + d.Set("enable_ip_forwarding", resp.EnableIPForwarding) + d.Set("enable_accelerated_networking", resp.EnableAcceleratedNetworking) } - d.Set("enable_ip_forwarding", resp.EnableIPForwarding) - d.Set("enable_accelerated_networking", resp.EnableAcceleratedNetworking) - flattenAndSetTags(d, resp.Tags) return nil diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index e451195853e3..65425e4bfeed 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -112,8 +112,8 @@ The following attributes are exported: * `id` - The Virtual Network Interface ID. * `mac_address` - The media access control (MAC) address of the network interface. -* `private_ip_address` - The private IP address of the network interface. -* `private_ip_address_version` - The private IP address version. +* `private_ip_address` - The first private IP address of the network interface. +* `private_ip_addresses` - The private IP addresses of the network interface. * `virtual_machine_id` - Reference to a VM with which this NIC has been associated. * `applied_dns_servers` - If the VM that uses this NIC is part of an Availability Set, then this list will have the union of all DNS servers from all NICs that are part of the Availability Set From 9ad4f58a69fa3aba8fd7df12e83848abe574a7c1 Mon Sep 17 00:00:00 2001 From: kt Date: Mon, 7 Jan 2019 02:44:15 -0800 Subject: [PATCH 6/7] make fmt goimport --- azurerm/resource_arm_network_interface.go | 1 - azurerm/resource_arm_network_interface_test.go | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/azurerm/resource_arm_network_interface.go b/azurerm/resource_arm_network_interface.go index b20528a4b10e..36fb96d8ce51 100644 --- a/azurerm/resource_arm_network_interface.go +++ b/azurerm/resource_arm_network_interface.go @@ -227,7 +227,6 @@ func resourceArmNetworkInterface() *schema.Resource { Computed: true, }, - "private_ip_addresses": { Type: schema.TypeList, Computed: true, diff --git a/azurerm/resource_arm_network_interface_test.go b/azurerm/resource_arm_network_interface_test.go index 7af0a09acd08..483d9b63b8bd 100644 --- a/azurerm/resource_arm_network_interface_test.go +++ b/azurerm/resource_arm_network_interface_test.go @@ -75,7 +75,7 @@ func testSweepNetworkInterfaces(region string) error { return nil } -func TestAccAzureRMNetworkInterface_basic(t *testing.T) { +func TestAccAzureRMNetworkInterface_disappears(t *testing.T) { resourceName := "azurerm_network_interface.test" rInt := acctest.RandInt() resource.ParallelTest(t, resource.TestCase{ @@ -87,18 +87,15 @@ func TestAccAzureRMNetworkInterface_basic(t *testing.T) { Config: testAccAzureRMNetworkInterface_basic(rInt, testLocation()), Check: resource.ComposeTestCheckFunc( testCheckAzureRMNetworkInterfaceExists(resourceName), + testCheckAzureRMNetworkInterfaceDisappears(resourceName), ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ExpectNonEmptyPlan: true, }, }, }) } -func TestAccAzureRMNetworkInterface_disappears(t *testing.T) { +func TestAccAzureRMNetworkInterface_basic(t *testing.T) { resourceName := "azurerm_network_interface.test" rInt := acctest.RandInt() resource.ParallelTest(t, resource.TestCase{ @@ -110,9 +107,12 @@ func TestAccAzureRMNetworkInterface_disappears(t *testing.T) { Config: testAccAzureRMNetworkInterface_basic(rInt, testLocation()), Check: resource.ComposeTestCheckFunc( testCheckAzureRMNetworkInterfaceExists(resourceName), - testCheckAzureRMNetworkInterfaceDisappears(resourceName), ), - ExpectNonEmptyPlan: true, + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, }, }, }) From 8c8f40cb5f4f7e169b250167b87e002a7c2d9e44 Mon Sep 17 00:00:00 2001 From: Tom Harvey Date: Mon, 7 Jan 2019 11:41:15 +0000 Subject: [PATCH 7/7] Quoting the possible values --- website/docs/r/network_interface.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/network_interface.html.markdown b/website/docs/r/network_interface.html.markdown index 65425e4bfeed..04cbafd745a4 100644 --- a/website/docs/r/network_interface.html.markdown +++ b/website/docs/r/network_interface.html.markdown @@ -86,7 +86,7 @@ The `ip_configuration` block supports: * `private_ip_address_allocation` - (Required) Defines how a private IP address is assigned. Options are Static or Dynamic. -* `private_ip_address_version` - (Optional) The IP Version to use, IPv6 or IPv4. Defaults to IPv4. +* `private_ip_address_version` - (Optional) The IP Version to use. Possible values are `IPv4` or `IPv6`. Defaults to `IPv4`. * `public_ip_address_id` - (Optional) Reference to a Public IP Address to associate with this NIC