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

Support multiple alternative locations for azurerm_api_management #4175

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
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",
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
}

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)
}