Skip to content

Commit

Permalink
azurerm_point_to_site_vpn_gateway - support mutiple `connection_con…
Browse files Browse the repository at this point in the history
…figurations` (#23936)

* support mutiple connection_configurations on resource azurerm_point_to_site_vpn_gateway

* update code
  • Loading branch information
sinbai authored Nov 20, 2023
1 parent a4347bc commit bb8fcb1
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb8fcb1

Please sign in to comment.