Skip to content
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_virtual_network_gateway: Add OpenVPN as a client protocol option #2126

Merged
merged 7 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 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,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`. **NOTE**: The OpenVPN protocol is currently in Public Preview. You need to [opt in to be able to use OpenVPN as an option](https://docs.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-howto-openvpn).
maetthu marked this conversation as resolved.
Show resolved Hide resolved

The `bgp_settings` block supports:

Expand Down