Skip to content

Commit

Permalink
Merge pull request #4175 from pdecat/api_management_additional_locations
Browse files Browse the repository at this point in the history
Support multiple alternative locations for azurerm_api_management
  • Loading branch information
tombuildsstuff authored Aug 29, 2019
2 parents da09b92 + 88e7013 commit b412970
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ The following Environment Variables must be set in your shell prior to running a
- `ARM_ENVIRONMENT`
- `ARM_TEST_LOCATION`
- `ARM_TEST_LOCATION_ALT`
- `ARM_TEST_LOCATION_ALT2`

**Note:** Acceptance tests create real resources in Azure which often cost money to run.

Expand Down
5 changes: 5 additions & 0 deletions azurerm/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func testAccPreCheck(t *testing.T) {
"ARM_TENANT_ID",
"ARM_TEST_LOCATION",
"ARM_TEST_LOCATION_ALT",
"ARM_TEST_LOCATION_ALT2",
}

for _, variable := range variables {
Expand All @@ -61,6 +62,10 @@ func testAltLocation() string {
return os.Getenv("ARM_TEST_LOCATION_ALT")
}

func testAltLocation2() string {
return os.Getenv("ARM_TEST_LOCATION_ALT2")
}

func testArmEnvironmentName() string {
envName, exists := os.LookupEnv("ARM_ENVIRONMENT")
if !exists {
Expand Down
1 change: 0 additions & 1 deletion azurerm/resource_arm_api_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func resourceArmApiManagementService() *schema.Resource {
"additional_location": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"location": azure.SchemaLocation(),
Expand Down
15 changes: 12 additions & 3 deletions azurerm/resource_arm_api_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestAccAzureRMApiManagement_customProps(t *testing.T) {
func TestAccAzureRMApiManagement_complete(t *testing.T) {
resourceName := "azurerm_api_management.test"
ri := tf.AccRandTimeInt()
config := testAccAzureRMApiManagement_complete(ri, testLocation(), testAltLocation())
config := testAccAzureRMApiManagement_complete(ri, testLocation(), testAltLocation(), testAltLocation2())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -442,7 +442,7 @@ resource "azurerm_api_management" "test" {
`, rInt, location, rInt)
}

func testAccAzureRMApiManagement_complete(rInt int, location string, altLocation string) string {
func testAccAzureRMApiManagement_complete(rInt int, location string, altLocation string, altLocation2 string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test1" {
name = "acctestRG-%d"
Expand All @@ -454,6 +454,11 @@ resource "azurerm_resource_group" "test2" {
location = "%s"
}
resource "azurerm_resource_group" "test3" {
name = "acctestRG3-%d"
location = "%s"
}
resource "azurerm_api_management" "test" {
name = "acctestAM-%d"
publisher_name = "pub1"
Expand All @@ -464,6 +469,10 @@ resource "azurerm_api_management" "test" {
location = "${azurerm_resource_group.test2.location}"
}
additional_location {
location = "${azurerm_resource_group.test3.location}"
}
certificate {
encoded_certificate = "${filebase64("testdata/api_management_api_test.pfx")}"
certificate_password = "terraform"
Expand Down Expand Up @@ -516,5 +525,5 @@ resource "azurerm_api_management" "test" {
location = "${azurerm_resource_group.test1.location}"
resource_group_name = "${azurerm_resource_group.test1.name}"
}
`, rInt, location, rInt, altLocation, rInt)
`, rInt, location, rInt, altLocation, rInt, altLocation2, rInt)
}

0 comments on commit b412970

Please sign in to comment.