Skip to content

Commit

Permalink
Merge pull request #2126 from maetthu/vnetgw-openvpn
Browse files Browse the repository at this point in the history
azurerm_virtual_network_gateway: Add OpenVPN as a client protocol option
  • Loading branch information
katbyte authored Oct 23, 2018
2 parents 455d209 + f4ab412 commit aff8710
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
1 change: 1 addition & 0 deletions azurerm/resource_arm_virtual_network_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ func resourceArmVirtualNetworkGateway() *schema.Resource {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{
string(network.IkeV2),
string(network.OpenVPN),
string(network.SSTP),
}, true),
},
Expand Down
73 changes: 73 additions & 0 deletions azurerm/resource_arm_virtual_network_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,27 @@ func TestAccAzureRMVirtualNetworkGateway_vpnClientConfig(t *testing.T) {
})
}

func TestAccAzureRMVirtualNetworkGateway_vpnClientConfigOpenVPN(t *testing.T) {
ri := acctest.RandInt()
resourceName := "azurerm_virtual_network_gateway.test"
config := testAccAzureRMVirtualNetworkGateway_vpnClientConfigOpenVPN(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualNetworkGatewayDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMVirtualNetworkGatewayExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "vpn_client_configuration.0.vpn_client_protocols.#", "1"),
),
},
},
})
}

func testCheckAzureRMVirtualNetworkGatewayExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
name, resourceGroup, err := getArmResourceNameAndGroup(s, name)
Expand Down Expand Up @@ -502,6 +523,58 @@ resource "azurerm_virtual_network_gateway" "test" {
`, rInt, location, rInt, rInt, rInt)
}

func testAccAzureRMVirtualNetworkGateway_vpnClientConfigOpenVPN(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_virtual_network" "test" {
name = "acctestvn-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
address_space = ["10.0.0.0/16"]
}
resource "azurerm_subnet" "test" {
name = "GatewaySubnet"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.1.0/24"
}
resource "azurerm_public_ip" "test" {
name = "acctestpip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Dynamic"
}
resource "azurerm_virtual_network_gateway" "test" {
depends_on = ["azurerm_public_ip.test"]
name = "acctestvng-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
type = "Vpn"
vpn_type = "RouteBased"
sku = "VpnGw1"
ip_configuration {
public_ip_address_id = "${azurerm_public_ip.test.id}"
private_ip_address_allocation = "Dynamic"
subnet_id = "${azurerm_subnet.test.id}"
}
vpn_client_configuration {
address_space = ["10.2.0.0/24"]
vpn_client_protocols = ["OpenVPN"]
}
}
`, rInt, location, rInt, rInt, rInt)
}

func testAccAzureRMVirtualNetworkGateway_sku(rInt int, location string, sku string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/virtual_network_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The `vpn_client_configuration` block supports:
This setting is incompatible with the use of `root_certificate` and `revoked_certificate`.

* `vpn_client_protocols` - (Optional) List of the protocols supported by the vpn client.
The supported values are `SSTP` and `IkeV2`.
The supported values are `SSTP`, `IkeV2` and `OpenVPN`.

The `bgp_settings` block supports:

Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/virtual_network_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ The `vpn_client_configuration` block supports:
This setting is incompatible with the use of `root_certificate` and `revoked_certificate`.

* `vpn_client_protocols` - (Optional) List of the protocols supported by the vpn client.
The supported values are `SSTP` and `IkeV2`.
The supported values are `SSTP`, `IkeV2` and `OpenVPN`.

-> **NOTE:** Support for `OpenVPN` as a Client Protocol is currently in Public Preview - [you can register for this Preview using this link](https://docs.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-howto-openvpn).

The `bgp_settings` block supports:

Expand Down

0 comments on commit aff8710

Please sign in to comment.