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_point_to_site_vpn_gateway - support mutiple connection_configurations #23936

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading