Skip to content

Commit 2c8c587

Browse files
committed
provider/azurerm: Add support for EnableIPForwarding to (hashicorp#6807)
`azurerm_network_interface` As requested in hashicorp#6803 ``` ```
1 parent 42c6864 commit 2c8c587

3 files changed

Lines changed: 65 additions & 1 deletion

File tree

builtin/providers/azurerm/resource_arm_network_interface_card.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ func resourceArmNetworkInterface() *schema.Resource {
145145
Computed: true,
146146
},
147147

148+
"enable_ip_forwarding": &schema.Schema{
149+
Type: schema.TypeBool,
150+
Optional: true,
151+
Default: false,
152+
},
153+
148154
"tags": tagsSchema(),
149155
},
150156
}
@@ -159,9 +165,12 @@ func resourceArmNetworkInterfaceCreate(d *schema.ResourceData, meta interface{})
159165
name := d.Get("name").(string)
160166
location := d.Get("location").(string)
161167
resGroup := d.Get("resource_group_name").(string)
168+
enableIpForwarding := d.Get("enable_ip_forwarding").(bool)
162169
tags := d.Get("tags").(map[string]interface{})
163170

164-
properties := network.InterfacePropertiesFormat{}
171+
properties := network.InterfacePropertiesFormat{
172+
EnableIPForwarding: &enableIpForwarding,
173+
}
165174

166175
if v, ok := d.GetOk("network_security_group_id"); ok {
167176
nsgId := v.(string)

builtin/providers/azurerm/resource_arm_network_interface_card_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ func TestAccAzureRMNetworkInterface_basic(t *testing.T) {
2626
})
2727
}
2828

29+
func TestAccAzureRMNetworkInterfaceenableIPForwarding(t *testing.T) {
30+
31+
resource.Test(t, resource.TestCase{
32+
PreCheck: func() { testAccPreCheck(t) },
33+
Providers: testAccProviders,
34+
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
35+
Steps: []resource.TestStep{
36+
resource.TestStep{
37+
Config: testAccAzureRMNetworkInterface_ipForwarding,
38+
Check: resource.ComposeTestCheckFunc(
39+
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
40+
resource.TestCheckResourceAttr(
41+
"azurerm_network_interface.test", "enable_ip_forwarding", "true"),
42+
),
43+
},
44+
},
45+
})
46+
}
47+
2948
func TestAccAzureRMNetworkInterface_withTags(t *testing.T) {
3049

3150
resource.Test(t, resource.TestCase{
@@ -176,6 +195,40 @@ resource "azurerm_network_interface" "test" {
176195
}
177196
`
178197

198+
var testAccAzureRMNetworkInterface_ipForwarding = `
199+
resource "azurerm_resource_group" "test" {
200+
name = "acceptanceTestResourceGroup1"
201+
location = "West US"
202+
}
203+
204+
resource "azurerm_virtual_network" "test" {
205+
name = "acceptanceTestVirtualNetwork1"
206+
address_space = ["10.0.0.0/16"]
207+
location = "West US"
208+
resource_group_name = "${azurerm_resource_group.test.name}"
209+
}
210+
211+
resource "azurerm_subnet" "test" {
212+
name = "testsubnet"
213+
resource_group_name = "${azurerm_resource_group.test.name}"
214+
virtual_network_name = "${azurerm_virtual_network.test.name}"
215+
address_prefix = "10.0.2.0/24"
216+
}
217+
218+
resource "azurerm_network_interface" "test" {
219+
name = "acceptanceTestNetworkInterface1"
220+
location = "West US"
221+
resource_group_name = "${azurerm_resource_group.test.name}"
222+
enable_ip_forwarding = true
223+
224+
ip_configuration {
225+
name = "testconfiguration1"
226+
subnet_id = "${azurerm_subnet.test.id}"
227+
private_ip_address_allocation = "dynamic"
228+
}
229+
}
230+
`
231+
179232
var testAccAzureRMNetworkInterface_withTags = `
180233
resource "azurerm_resource_group" "test" {
181234
name = "acceptanceTestResourceGroup1"

website/source/docs/providers/azurerm/r/network_interface.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ The following arguments are supported:
6767

6868
* `internal_dns_name_label` - (Optional) Relative DNS name for this NIC used for internal communications between VMs in the same VNet
6969

70+
* `enable_ip_forwarding` - (Optional) Enables IP Forwarding on the NIC. Defaults to `false`.
71+
7072
* `dns_servers` - (Optional) List of DNS servers IP addresses to use for this NIC, overrides the VNet-level server list
7173

7274
* `ip_configuration` - (Optional) Collection of ipConfigurations associated with this NIC. Each `ip_configuration` block supports fields documented below.

0 commit comments

Comments
 (0)