-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_network_interface
- Support auxiliary_mode
, auxiliary_sku
#22979
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -126,6 +126,32 @@ func resourceNetworkInterface() *pluginsdk.Resource { | |||||||||
}, | ||||||||||
|
||||||||||
// Optional | ||||||||||
"auxiliary_mode": { | ||||||||||
Type: pluginsdk.TypeString, | ||||||||||
Optional: true, | ||||||||||
ValidateFunc: validation.StringInSlice([]string{ | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliaryModeAcceleratedConnections), | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliaryModeFloating), | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliaryModeNone), | ||||||||||
}, false), | ||||||||||
Default: string(networkinterfaces.NetworkInterfaceAuxiliaryModeNone), | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need to expose
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code updated |
||||||||||
RequiredWith: []string{"auxiliary_sku"}, | ||||||||||
}, | ||||||||||
|
||||||||||
"auxiliary_sku": { | ||||||||||
Type: pluginsdk.TypeString, | ||||||||||
Optional: true, | ||||||||||
ValidateFunc: validation.StringInSlice([]string{ | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliarySkuAEight), | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliarySkuAFour), | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliarySkuAOne), | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliarySkuATwo), | ||||||||||
string(networkinterfaces.NetworkInterfaceAuxiliarySkuNone), | ||||||||||
}, false), | ||||||||||
Default: string(networkinterfaces.NetworkInterfaceAuxiliarySkuNone), | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same here)
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code updated |
||||||||||
RequiredWith: []string{"auxiliary_mode"}, | ||||||||||
}, | ||||||||||
|
||||||||||
"dns_servers": { | ||||||||||
Type: pluginsdk.TypeList, | ||||||||||
Optional: true, | ||||||||||
|
@@ -232,6 +258,14 @@ func resourceNetworkInterfaceCreate(d *pluginsdk.ResourceData, meta interface{}) | |||||||||
locks.ByName(id.NetworkInterfaceName, networkInterfaceResourceName) | ||||||||||
defer locks.UnlockByName(id.NetworkInterfaceName, networkInterfaceResourceName) | ||||||||||
|
||||||||||
if auxiliaryMode, hasAuxiliaryMode := d.GetOk("auxiliary_mode"); hasAuxiliaryMode { | ||||||||||
properties.AuxiliaryMode = pointer.To(networkinterfaces.NetworkInterfaceAuxiliaryMode(auxiliaryMode.(string))) | ||||||||||
} | ||||||||||
|
||||||||||
if auxiliarySku, hasAuxiliarySku := d.GetOk("auxiliary_sku"); hasAuxiliarySku { | ||||||||||
properties.AuxiliarySku = pointer.To(networkinterfaces.NetworkInterfaceAuxiliarySku(auxiliarySku.(string))) | ||||||||||
} | ||||||||||
|
||||||||||
dns, hasDns := d.GetOk("dns_servers") | ||||||||||
nameLabel, hasNameLabel := d.GetOk("internal_dns_name_label") | ||||||||||
if hasDns || hasNameLabel { | ||||||||||
|
@@ -325,6 +359,22 @@ func resourceNetworkInterfaceUpdate(d *pluginsdk.ResourceData, meta interface{}) | |||||||||
}, | ||||||||||
} | ||||||||||
|
||||||||||
if d.HasChange("auxiliary_mode") { | ||||||||||
if auxiliaryMode, hasAuxiliaryMode := d.GetOk("auxiliary_mode"); hasAuxiliaryMode { | ||||||||||
update.Properties.AuxiliaryMode = pointer.To(networkinterfaces.NetworkInterfaceAuxiliaryMode(auxiliaryMode.(string))) | ||||||||||
} | ||||||||||
} else { | ||||||||||
update.Properties.AuxiliaryMode = existing.Model.Properties.AuxiliaryMode | ||||||||||
} | ||||||||||
Comment on lines
+350
to
+356
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how do users unset this property? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If users remove this property from the .tf, the code will enter |
||||||||||
|
||||||||||
if d.HasChange("auxiliary_sku") { | ||||||||||
if auxiliarySku, hasAuxiliarySku := d.GetOk("auxiliary_sku"); hasAuxiliarySku { | ||||||||||
update.Properties.AuxiliarySku = pointer.To(networkinterfaces.NetworkInterfaceAuxiliarySku(auxiliarySku.(string))) | ||||||||||
} | ||||||||||
} else { | ||||||||||
update.Properties.AuxiliarySku = existing.Model.Properties.AuxiliarySku | ||||||||||
} | ||||||||||
tombuildsstuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
if d.HasChange("dns_servers") { | ||||||||||
dnsServersRaw := d.Get("dns_servers").([]interface{}) | ||||||||||
dnsServers := expandNetworkInterfaceDnsServers(dnsServersRaw) | ||||||||||
|
@@ -462,6 +512,8 @@ func resourceNetworkInterfaceRead(d *pluginsdk.ResourceData, meta interface{}) e | |||||||||
return fmt.Errorf("setting `applied_dns_servers`: %+v", err) | ||||||||||
} | ||||||||||
|
||||||||||
d.Set("auxiliary_mode", pointer.From(props.AuxiliaryMode)) | ||||||||||
d.Set("auxiliary_sku", pointer.From(props.AuxiliarySku)) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these'll both need to be normalized on the way back, since this won't be returned for older NICs - therefore None ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code updated |
||||||||||
d.Set("enable_ip_forwarding", props.EnableIPForwarding) | ||||||||||
d.Set("enable_accelerated_networking", props.EnableAcceleratedNetworking) | ||||||||||
d.Set("internal_dns_name_label", internalDnsNameLabel) | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,34 @@ func TestAccNetworkInterface_disappears(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccNetworkInterface_auxiliary(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_network_interface", "test") | ||
r := NetworkInterfaceResource{} | ||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.auxiliary(data, "", ""), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
{ | ||
Config: r.auxiliary(data, "AcceleratedConnections", "A2"), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
{ | ||
Config: r.auxiliary(data, "", ""), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}) | ||
} | ||
|
||
func TestAccNetworkInterface_dnsServers(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_network_interface", "test") | ||
r := NetworkInterfaceResource{} | ||
|
@@ -388,6 +416,43 @@ resource "azurerm_network_interface" "test" { | |
`, r.template(data), data.RandomInteger) | ||
} | ||
|
||
func (r NetworkInterfaceResource) auxiliary(data acceptance.TestData, mode string, sku string) string { | ||
// Auxiliary Mode Nic is enabled in specific regions (https://learn.microsoft.com/en-us/azure/networking/nva-accelerated-connections#supported-regions) for now | ||
// To not affect other testcases of `Network`, hard-code to that for now | ||
data.Locations.Primary = "westus" | ||
|
||
if mode != "" { | ||
mode = fmt.Sprintf(`auxiliary_mode = "%s"`, mode) | ||
} | ||
|
||
if sku != "" { | ||
sku = fmt.Sprintf(`auxiliary_sku = "%s"`, sku) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it'd be easier/clearer to use separate test templates here - so can we update this to be one test template per type? In addition, since these two fields must be specified together, this conditional logic would lead to an invalid configuration - another reason to use a separate test template here to make that clearer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code updated |
||
|
||
return fmt.Sprintf(` | ||
%s | ||
|
||
resource "azurerm_network_interface" "test" { | ||
name = "acctestni-%d" | ||
location = "%s" | ||
resource_group_name = azurerm_resource_group.test.name | ||
%s | ||
%s | ||
enable_accelerated_networking = true | ||
|
||
ip_configuration { | ||
name = "primary" | ||
subnet_id = azurerm_subnet.test.id | ||
private_ip_address_allocation = "Dynamic" | ||
} | ||
|
||
tags = { | ||
fastpathenabled = "true" | ||
tombuildsstuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
`, r.template(data), data.RandomInteger, data.Locations.Primary, mode, sku) | ||
} | ||
|
||
func (r NetworkInterfaceResource) withMultipleParameters(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
%s | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -60,6 +60,12 @@ The following arguments are supported: | |||||
|
||||||
--- | ||||||
|
||||||
* `auxiliary_mode` - (Optional) The Auxiliary mode of the Network Interface. Possible values are `AcceleratedConnections`, `Floating` and `None`. Defaults to `None`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. firstly:
Suggested change
secondly, what does this do? this description isn't clear/descriptive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. firstly: doc updated. |
||||||
|
||||||
-> **Note:** This field requires the preview feature is enabled. See the [Prerequisites](https://learn.microsoft.com/en-us/azure/networking/nva-accelerated-connections#prerequisites) for more details. | ||||||
|
||||||
* `auxiliary_sku` - (Optional) The Auxiliary SKU of the Network Interface. Possible values are `A1`, `A2`, `A4`, `A8` and `None`. Defaults to `None`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. firstly: does this require the preview feature too? secondly:
Suggested change
thirdly: what does this do? this description isn't clear/descriptive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. firstly: Yes, I updated the doc for both of them |
||||||
|
||||||
* `dns_servers` - (Optional) A list of IP Addresses defining the DNS Servers which should be used for this Network Interface. | ||||||
|
||||||
-> **Note:** Configuring DNS Servers on the Network Interface will override the DNS Servers defined on the Virtual Network. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use
possiblevaluesfor
here fwiwThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code updated. Thanks.