-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8290 from jake-scott/iss6642-vnet-in-additional-locs
API Manager: Support for virtual network mode with additional locations
- Loading branch information
Showing
6 changed files
with
276 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,30 @@ func TestAccDataSourceAzureRMApiManagement_basic(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccDataSourceAzureRMApiManagement_virtualNetwork(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "data.azurerm_api_management", "test") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { acceptance.PreCheck(t) }, | ||
Providers: acceptance.SupportedProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceApiManagement_virtualNetwork(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(data.ResourceName, "publisher_email", "[email protected]"), | ||
resource.TestCheckResourceAttr(data.ResourceName, "publisher_name", "pub1"), | ||
resource.TestCheckResourceAttr(data.ResourceName, "sku_name", "Premium_1"), | ||
resource.TestCheckResourceAttr(data.ResourceName, "tags.%", "0"), | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "public_ip_addresses.#"), | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "private_ip_addresses.#"), | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "additional_location.0.public_ip_addresses.#"), | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "additional_location.0.private_ip_addresses.#"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceApiManagement_basic(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
|
@@ -55,3 +79,76 @@ data "azurerm_api_management" "test" { | |
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) | ||
} | ||
|
||
func testAccDataSourceApiManagement_virtualNetwork(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
resource "azurerm_resource_group" "test1" { | ||
name = "amestRG1-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_resource_group" "test2" { | ||
name = "amestRG2-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_virtual_network" "test1" { | ||
name = "amtestVNET1-%d" | ||
location = azurerm_resource_group.test1.location | ||
resource_group_name = azurerm_resource_group.test1.name | ||
address_space = ["10.0.0.0/16"] | ||
} | ||
resource "azurerm_subnet" "test1" { | ||
name = "amtestSNET1-%d" | ||
resource_group_name = azurerm_resource_group.test1.name | ||
virtual_network_name = azurerm_virtual_network.test1.name | ||
address_prefix = "10.0.1.0/24" | ||
} | ||
resource "azurerm_virtual_network" "test2" { | ||
name = "amtestVNET2-%d" | ||
location = azurerm_resource_group.test2.location | ||
resource_group_name = azurerm_resource_group.test2.name | ||
address_space = ["10.1.0.0/16"] | ||
} | ||
resource "azurerm_subnet" "test2" { | ||
name = "amtestSNET2-%d" | ||
resource_group_name = azurerm_resource_group.test2.name | ||
virtual_network_name = azurerm_virtual_network.test2.name | ||
address_prefix = "10.1.1.0/24" | ||
} | ||
resource "azurerm_api_management" "test" { | ||
name = "amtestAM-%d" | ||
location = azurerm_resource_group.test1.location | ||
resource_group_name = azurerm_resource_group.test1.name | ||
publisher_name = "pub1" | ||
publisher_email = "[email protected]" | ||
sku_name = "Premium_1" | ||
additional_location { | ||
location = azurerm_resource_group.test2.location | ||
virtual_network_configuration { | ||
subnet_id = azurerm_subnet.test2.id | ||
} | ||
} | ||
virtual_network_type = "Internal" | ||
virtual_network_configuration { | ||
subnet_id = azurerm_subnet.test1.id | ||
} | ||
} | ||
data "azurerm_api_management" "test" { | ||
name = azurerm_api_management.test.name | ||
resource_group_name = azurerm_api_management.test.resource_group_name | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,6 +175,29 @@ func TestAccAzureRMApiManagement_virtualNetworkInternal(t *testing.T) { | |
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMApiManagementExists(data.ResourceName), | ||
resource.TestCheckResourceAttr(data.ResourceName, "virtual_network_type", "Internal"), | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "private_ip_addresses.#"), | ||
), | ||
}, | ||
data.ImportStep(), | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAzureRMApiManagement_virtualNetworkInternalAdditionalLocation(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_api_management", "test") | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { acceptance.PreCheck(t) }, | ||
Providers: acceptance.SupportedProviders, | ||
CheckDestroy: testCheckAzureRMApiManagementDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAzureRMApiManagement_virtualNetworkInternalAdditionalLocation(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMApiManagementExists(data.ResourceName), | ||
resource.TestCheckResourceAttr(data.ResourceName, "virtual_network_type", "Internal"), | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "private_ip_addresses.#"), | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "additional_location.0.private_ip_addresses.#"), | ||
), | ||
}, | ||
data.ImportStep(), | ||
|
@@ -891,6 +914,74 @@ resource "azurerm_api_management" "test" { | |
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger) | ||
} | ||
|
||
func testAccAzureRMApiManagement_virtualNetworkInternalAdditionalLocation(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
resource "azurerm_resource_group" "test1" { | ||
name = "acctestRG1-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_resource_group" "test2" { | ||
name = "acctestRG2-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_virtual_network" "test1" { | ||
name = "acctestVNET1-%d" | ||
location = azurerm_resource_group.test1.location | ||
resource_group_name = azurerm_resource_group.test1.name | ||
address_space = ["10.0.0.0/16"] | ||
} | ||
resource "azurerm_subnet" "test1" { | ||
name = "acctestSNET1-%d" | ||
resource_group_name = azurerm_resource_group.test1.name | ||
virtual_network_name = azurerm_virtual_network.test1.name | ||
address_prefix = "10.0.1.0/24" | ||
} | ||
resource "azurerm_virtual_network" "test2" { | ||
name = "acctestVNET2-%d" | ||
location = azurerm_resource_group.test2.location | ||
resource_group_name = azurerm_resource_group.test2.name | ||
address_space = ["10.1.0.0/16"] | ||
} | ||
resource "azurerm_subnet" "test2" { | ||
name = "acctestSNET2-%d" | ||
resource_group_name = azurerm_resource_group.test2.name | ||
virtual_network_name = azurerm_virtual_network.test2.name | ||
address_prefix = "10.1.1.0/24" | ||
} | ||
resource "azurerm_api_management" "test" { | ||
name = "acctestAM-%d" | ||
location = azurerm_resource_group.test1.location | ||
resource_group_name = azurerm_resource_group.test1.name | ||
publisher_name = "pub1" | ||
publisher_email = "[email protected]" | ||
sku_name = "Premium_1" | ||
additional_location { | ||
location = azurerm_resource_group.test2.location | ||
virtual_network_configuration { | ||
subnet_id = azurerm_subnet.test2.id | ||
} | ||
} | ||
virtual_network_type = "Internal" | ||
virtual_network_configuration { | ||
subnet_id = azurerm_subnet.test1.id | ||
} | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) | ||
} | ||
|
||
func testAccAzureRMApiManagement_identityUserAssigned(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
|
Oops, something went wrong.