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_api_management - Property additional_location no longer forces a new resource. #12468

Merged
merged 3 commits into from
Jul 7, 2021
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 @@ -13,6 +13,7 @@ import (
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/parse"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/schemaz"
apimValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/apimanagement/validate"
Expand Down Expand Up @@ -180,7 +181,7 @@ func resourceApiManagementService() *pluginsdk.Resource {
Optional: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"location": azure.SchemaLocation(),
"location": location.SchemaWithoutForceNew(),

"virtual_network_configuration": {
Type: pluginsdk.TypeList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,46 @@ func TestAccApiManagement_complete(t *testing.T) {
})
}

func TestAccApiManagement_completeUpdateAdditionalLocations(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_api_management", "test")
r := ApiManagementResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("certificate", // not returned from API, sensitive
"hostname_configuration.0.portal.0.certificate", // not returned from API, sensitive
"hostname_configuration.0.portal.0.certificate_password", // not returned from API, sensitive
"hostname_configuration.0.developer_portal.0.certificate", // not returned from API, sensitive
"hostname_configuration.0.developer_portal.0.certificate_password", // not returned from API, sensitive
"hostname_configuration.0.proxy.0.certificate", // not returned from API, sensitive
"hostname_configuration.0.proxy.0.certificate_password", // not returned from API, sensitive
"hostname_configuration.0.proxy.1.certificate", // not returned from API, sensitive
"hostname_configuration.0.proxy.1.certificate_password", // not returned from API, sensitive
),
{
Config: r.completeUpdateAdditionalLocations(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("certificate", // not returned from API, sensitive
"hostname_configuration.0.portal.0.certificate", // not returned from API, sensitive
"hostname_configuration.0.portal.0.certificate_password", // not returned from API, sensitive
"hostname_configuration.0.developer_portal.0.certificate", // not returned from API, sensitive
"hostname_configuration.0.developer_portal.0.certificate_password", // not returned from API, sensitive
"hostname_configuration.0.proxy.0.certificate", // not returned from API, sensitive
"hostname_configuration.0.proxy.0.certificate_password", // not returned from API, sensitive
"hostname_configuration.0.proxy.1.certificate", // not returned from API, sensitive
"hostname_configuration.0.proxy.1.certificate_password", // not returned from API, sensitive
),
})
}

func TestAccApiManagement_signInSignUpSettings(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_api_management", "test")
r := ApiManagementResource{}
Expand Down Expand Up @@ -978,6 +1018,124 @@ resource "azurerm_api_management" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary, data.RandomInteger, data.Locations.Ternary, data.RandomInteger)
}

func (ApiManagementResource) completeUpdateAdditionalLocations(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test1" {
name = "acctestRG-api1-%d"
location = "%s"
}

resource "azurerm_resource_group" "test2" {
name = "acctestRG-api2-%d"
location = "%s"
}

resource "azurerm_resource_group" "test3" {
name = "acctestRG-api3-%d"
location = "%s"
}

resource "azurerm_api_management" "test" {
name = "acctestAM-%d"
publisher_name = "pub1"
publisher_email = "[email protected]"
notification_sender_email = "[email protected]"

additional_location {
location = azurerm_resource_group.test2.location
}

certificate {
encoded_certificate = filebase64("testdata/api_management_api_test.pfx")
certificate_password = "terraform"
store_name = "CertificateAuthority"
}

certificate {
encoded_certificate = filebase64("testdata/api_management_api_test.pfx")
certificate_password = "terraform"
store_name = "Root"
}

certificate {
encoded_certificate = filebase64("testdata/api_management_api_test.cer")
store_name = "Root"
}

certificate {
encoded_certificate = filebase64("testdata/api_management_api_test.cer")
store_name = "CertificateAuthority"
}

protocols {
enable_http2 = true
}

security {
enable_backend_tls11 = true
enable_backend_ssl30 = true
enable_backend_tls10 = true
enable_frontend_ssl30 = true
enable_frontend_tls10 = true
enable_frontend_tls11 = true
tls_ecdhe_ecdsa_with_aes128_cbc_sha_ciphers_enabled = true
tls_ecdhe_ecdsa_with_aes256_cbc_sha_ciphers_enabled = true
tls_ecdhe_rsa_with_aes128_cbc_sha_ciphers_enabled = true
tls_ecdhe_rsa_with_aes256_cbc_sha_ciphers_enabled = true
tls_rsa_with_aes128_cbc_sha256_ciphers_enabled = true
tls_rsa_with_aes128_cbc_sha_ciphers_enabled = true
tls_rsa_with_aes128_gcm_sha256_ciphers_enabled = true
tls_rsa_with_aes256_cbc_sha256_ciphers_enabled = true
tls_rsa_with_aes256_cbc_sha_ciphers_enabled = true
triple_des_ciphers_enabled = true
}

hostname_configuration {
proxy {
host_name = "api.terraform.io"
certificate = filebase64("testdata/api_management_api_test.pfx")
certificate_password = "terraform"
default_ssl_binding = true
negotiate_client_certificate = false
}

proxy {
host_name = "api2.terraform.io"
certificate = filebase64("testdata/api_management_api2_test.pfx")
certificate_password = "terraform"
negotiate_client_certificate = true
}

portal {
host_name = "portal.terraform.io"
certificate = filebase64("testdata/api_management_portal_test.pfx")
certificate_password = "terraform"
}

developer_portal {
host_name = "developer-portal.terraform.io"
certificate = filebase64("testdata/api_management_developer_portal_test.pfx")
}
}

sku_name = "Premium_2"

zones = [1, 2]

tags = {
"Acceptance" = "Test"
}

location = azurerm_resource_group.test1.location
resource_group_name = azurerm_resource_group.test1.name
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Locations.Secondary, data.RandomInteger, data.Locations.Ternary, data.RandomInteger)
}

func (ApiManagementResource) virtualNetworkTemplate(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down