Skip to content

Commit

Permalink
provider/azurerm: Add support for EnableIPForwarding to (#6807)
Browse files Browse the repository at this point in the history
`azurerm_network_interface`

As requested in #6803

```

```
  • Loading branch information
stack72 committed May 20, 2016
1 parent 42c6864 commit 2c8c587
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
11 changes: 10 additions & 1 deletion builtin/providers/azurerm/resource_arm_network_interface_card.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ func resourceArmNetworkInterface() *schema.Resource {
Computed: true,
},

"enable_ip_forwarding": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"tags": tagsSchema(),
},
}
Expand All @@ -159,9 +165,12 @@ func resourceArmNetworkInterfaceCreate(d *schema.ResourceData, meta interface{})
name := d.Get("name").(string)
location := d.Get("location").(string)
resGroup := d.Get("resource_group_name").(string)
enableIpForwarding := d.Get("enable_ip_forwarding").(bool)
tags := d.Get("tags").(map[string]interface{})

properties := network.InterfacePropertiesFormat{}
properties := network.InterfacePropertiesFormat{
EnableIPForwarding: &enableIpForwarding,
}

if v, ok := d.GetOk("network_security_group_id"); ok {
nsgId := v.(string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ func TestAccAzureRMNetworkInterface_basic(t *testing.T) {
})
}

func TestAccAzureRMNetworkInterfaceenableIPForwarding(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMNetworkInterfaceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAzureRMNetworkInterface_ipForwarding,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMNetworkInterfaceExists("azurerm_network_interface.test"),
resource.TestCheckResourceAttr(
"azurerm_network_interface.test", "enable_ip_forwarding", "true"),
),
},
},
})
}

func TestAccAzureRMNetworkInterface_withTags(t *testing.T) {

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -176,6 +195,40 @@ resource "azurerm_network_interface" "test" {
}
`

var testAccAzureRMNetworkInterface_ipForwarding = `
resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1"
location = "West US"
}
resource "azurerm_virtual_network" "test" {
name = "acceptanceTestVirtualNetwork1"
address_space = ["10.0.0.0/16"]
location = "West US"
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_network_interface" "test" {
name = "acceptanceTestNetworkInterface1"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
enable_ip_forwarding = true
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.test.id}"
private_ip_address_allocation = "dynamic"
}
}
`

var testAccAzureRMNetworkInterface_withTags = `
resource "azurerm_resource_group" "test" {
name = "acceptanceTestResourceGroup1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ The following arguments are supported:

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

* `enable_ip_forwarding` - (Optional) Enables IP Forwarding on the NIC. Defaults to `false`.

* `dns_servers` - (Optional) List of DNS servers IP addresses to use for this NIC, overrides the VNet-level server list

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

0 comments on commit 2c8c587

Please sign in to comment.