From dbdd3df2bdab9ee8a7d50227bfddf5bbe8e795d4 Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Fri, 17 Nov 2023 13:28:12 +0800 Subject: [PATCH 1/2] support mutiple connection_configurations on resource azurerm_point_to_site_vpn_gateway --- .../point_to_site_vpn_gateway_resource.go | 3 - ...point_to_site_vpn_gateway_resource_test.go | 80 +++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/internal/services/network/point_to_site_vpn_gateway_resource.go b/internal/services/network/point_to_site_vpn_gateway_resource.go index 409e54e9627b..c553e4330fec 100644 --- a/internal/services/network/point_to_site_vpn_gateway_resource.go +++ b/internal/services/network/point_to_site_vpn_gateway_resource.go @@ -71,9 +71,6 @@ func resourcePointToSiteVPNGateway() *pluginsdk.Resource { "connection_configuration": { Type: pluginsdk.TypeList, Required: true, - // Code="P2SVpnGatewayCanHaveOnlyOneP2SConnectionConfiguration" - // Message="Currently, P2SVpnGateway [ID] can have only one P2SConnectionConfiguration. Specified number of P2SConnectionConfiguration are 2. - MaxItems: 1, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "name": { diff --git a/internal/services/network/point_to_site_vpn_gateway_resource_test.go b/internal/services/network/point_to_site_vpn_gateway_resource_test.go index 0dc7e35d4c54..de0c17d73346 100644 --- a/internal/services/network/point_to_site_vpn_gateway_resource_test.go +++ b/internal/services/network/point_to_site_vpn_gateway_resource_test.go @@ -33,6 +33,35 @@ func TestAccPointToSiteVPNGateway_basic(t *testing.T) { }) } +func TestAccPointToSiteVPNGateway_connectionConfiguration(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_point_to_site_vpn_gateway", "test") + r := PointToSiteVPNGatewayResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.singleConnectionConfiguration(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.multipleConnectionConfiguration(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + { + Config: r.singleConnectionConfiguration(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccPointToSiteVPNGateway_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_point_to_site_vpn_gateway", "test") r := PointToSiteVPNGatewayResource{} @@ -155,6 +184,57 @@ resource "azurerm_point_to_site_vpn_gateway" "test" { `, r.template(data), data.RandomInteger) } +func (r PointToSiteVPNGatewayResource) singleConnectionConfiguration(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_point_to_site_vpn_gateway" "test" { + name = "acctestp2sVPNG-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + virtual_hub_id = azurerm_virtual_hub.test.id + vpn_server_configuration_id = azurerm_vpn_server_configuration.test.id + scale_unit = 1 + + connection_configuration { + name = "first" + vpn_client_address_pool { + address_prefixes = ["172.100.0.0/25"] + } + } +} +`, r.template(data), data.RandomInteger) +} + +func (r PointToSiteVPNGatewayResource) multipleConnectionConfiguration(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_point_to_site_vpn_gateway" "test" { + name = "acctestp2sVPNG-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + virtual_hub_id = azurerm_virtual_hub.test.id + vpn_server_configuration_id = azurerm_vpn_server_configuration.test.id + scale_unit = 1 + + connection_configuration { + name = "second" + vpn_client_address_pool { + address_prefixes = ["172.100.128.0/25"] + } + } + + connection_configuration { + name = "first" + vpn_client_address_pool { + address_prefixes = ["172.100.0.0/25"] + } + } +} +`, r.template(data), data.RandomInteger) +} + func (r PointToSiteVPNGatewayResource) enableInternetSecurity(data acceptance.TestData) string { return fmt.Sprintf(` %s From 3881ec8936cd6186e040e4fafd1b02bc0ced61e3 Mon Sep 17 00:00:00 2001 From: Elena Xin Date: Fri, 17 Nov 2023 13:51:37 +0800 Subject: [PATCH 2/2] update code --- .../network/point_to_site_vpn_gateway_resource_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/network/point_to_site_vpn_gateway_resource_test.go b/internal/services/network/point_to_site_vpn_gateway_resource_test.go index de0c17d73346..85e0d3c6f045 100644 --- a/internal/services/network/point_to_site_vpn_gateway_resource_test.go +++ b/internal/services/network/point_to_site_vpn_gateway_resource_test.go @@ -196,7 +196,7 @@ resource "azurerm_point_to_site_vpn_gateway" "test" { vpn_server_configuration_id = azurerm_vpn_server_configuration.test.id scale_unit = 1 - connection_configuration { + connection_configuration { name = "first" vpn_client_address_pool { address_prefixes = ["172.100.0.0/25"] @@ -218,17 +218,17 @@ resource "azurerm_point_to_site_vpn_gateway" "test" { vpn_server_configuration_id = azurerm_vpn_server_configuration.test.id scale_unit = 1 - connection_configuration { + connection_configuration { name = "second" vpn_client_address_pool { address_prefixes = ["172.100.128.0/25"] } } - connection_configuration { + connection_configuration { name = "first" vpn_client_address_pool { - address_prefixes = ["172.100.0.0/25"] + address_prefixes = ["172.100.0.0/25"] } } }