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 the Developer Portal type of hostname_configuration in azurerm_api_management #6724

Merged
merged 1 commit into from May 13, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -124,6 +124,13 @@ func dataSourceApiManagementService() *schema.Resource {
Schema: apiManagementDataSourceHostnameSchema(),
},
},
"developer_portal": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: apiManagementDataSourceHostnameSchema(),
},
},
"proxy": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -207,6 +214,7 @@ func flattenDataSourceApiManagementHostnameConfigurations(input *[]apimanagement
managementResults := make([]interface{}, 0)
proxyResults := make([]interface{}, 0)
portalResults := make([]interface{}, 0)
developerPortalResults := make([]interface{}, 0)
scmResults := make([]interface{}, 0)

for _, config := range *input {
Expand Down Expand Up @@ -238,17 +246,21 @@ func flattenDataSourceApiManagementHostnameConfigurations(input *[]apimanagement
case strings.ToLower(string(apimanagement.HostnameTypePortal)):
portalResults = append(portalResults, output)

case strings.ToLower(string(apimanagement.HostnameTypeDeveloperPortal)):
developerPortalResults = append(developerPortalResults, output)

case strings.ToLower(string(apimanagement.HostnameTypeScm)):
scmResults = append(scmResults, output)
}
}

return []interface{}{
map[string]interface{}{
"management": managementResults,
"portal": portalResults,
"proxy": proxyResults,
"scm": scmResults,
"management": managementResults,
"portal": portalResults,
"developer_portal": developerPortalResults,
"proxy": proxyResults,
"scm": scmResults,
},
}
}
Expand Down
27 changes: 23 additions & 4 deletions azurerm/internal/services/apimanagement/api_management_resource.go
Expand Up @@ -278,6 +278,13 @@ func resourceArmApiManagementService() *schema.Resource {
Schema: apiManagementResourceHostnameSchema("portal"),
},
},
"developer_portal": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: apiManagementResourceHostnameSchema("developer_portal"),
},
},
"proxy": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -711,6 +718,13 @@ func expandAzureRmApiManagementHostnameConfigurations(d *schema.ResourceData) *[
results = append(results, output)
}

developerPortalVs := hostnameV["developer_portal"].([]interface{})
for _, developerPortalV := range developerPortalVs {
v := developerPortalV.(map[string]interface{})
output := expandApiManagementCommonHostnameConfiguration(v, apimanagement.HostnameTypeDeveloperPortal)
results = append(results, output)
}

proxyVs := hostnameV["proxy"].([]interface{})
for _, proxyV := range proxyVs {
v := proxyV.(map[string]interface{})
Expand Down Expand Up @@ -761,6 +775,7 @@ func flattenApiManagementHostnameConfigurations(input *[]apimanagement.HostnameC

managementResults := make([]interface{}, 0)
portalResults := make([]interface{}, 0)
developerPortalResults := make([]interface{}, 0)
proxyResults := make([]interface{}, 0)
scmResults := make([]interface{}, 0)

Expand Down Expand Up @@ -813,17 +828,21 @@ func flattenApiManagementHostnameConfigurations(input *[]apimanagement.HostnameC
case strings.ToLower(string(apimanagement.HostnameTypePortal)):
portalResults = append(portalResults, output)

case strings.ToLower(string(apimanagement.HostnameTypeDeveloperPortal)):
developerPortalResults = append(developerPortalResults, output)

case strings.ToLower(string(apimanagement.HostnameTypeScm)):
scmResults = append(scmResults, output)
}
}

return []interface{}{
map[string]interface{}{
"management": managementResults,
"portal": portalResults,
"proxy": proxyResults,
"scm": scmResults,
"management": managementResults,
"portal": portalResults,
"developer_portal": developerPortalResults,
"proxy": proxyResults,
"scm": scmResults,
},
}
}
Expand Down
Expand Up @@ -84,6 +84,10 @@ func TestAccAzureRMApiManagement_complete(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "tags.Acceptance", "Test"),
resource.TestCheckResourceAttrSet(data.ResourceName, "public_ip_addresses.#"),
resource.TestCheckResourceAttr(data.ResourceName, "protocols.0.enable_http2", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "hostname_configuration.0.proxy.0.host_name", "api.terraform.io"),
resource.TestCheckResourceAttr(data.ResourceName, "hostname_configuration.0.proxy.1.host_name", "api2.terraform.io"),
resource.TestCheckResourceAttr(data.ResourceName, "hostname_configuration.0.portal.0.host_name", "portal.terraform.io"),
resource.TestCheckResourceAttr(data.ResourceName, "hostname_configuration.0.developer_portal.0.host_name", "developer-portal.terraform.io"),
),
},
{
Expand All @@ -92,12 +96,14 @@ func TestAccAzureRMApiManagement_complete(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"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.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
"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
},
},
},
Expand Down Expand Up @@ -513,6 +519,12 @@ resource "azurerm_api_management" "test" {
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")
certificate_password = "terraform"
}
}

sku_name = "Premium_1"
Expand Down
12 changes: 12 additions & 0 deletions website/docs/d/api_management.html.markdown
Expand Up @@ -79,6 +79,8 @@ A `hostname_configuration` block exports the following:

* `portal` - One or more `portal` blocks as documented below.

* `developer_portal` - One or more `developer_portal` blocks as documented below.

* `proxy` - One or more `proxy` blocks as documented below.

* `scm` - One or more `scm` blocks as documented below.
Expand All @@ -105,6 +107,16 @@ A `portal` block exports the following:

---

A `developer_portal` block exports the following:

* `host_name` - The Hostname used for the Portal.

* `key_vault_id` - The ID of the Key Vault Secret which contains the SSL Certificate.

* `negotiate_client_certificate` - Is Client Certificate Negotiation enabled?

---

A `proxy` block exports the following:

* `default_ssl_binding` - Is this the default SSL Binding?
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/api_management.html.markdown
Expand Up @@ -110,6 +110,8 @@ A `hostname_configuration` block supports the following:

* `portal` - (Optional) One or more `portal` blocks as documented below.

* `developer_portal` - (Optional) One or more `developer_portal` blocks as documented below.

* `proxy` - (Optional) One or more `proxy` blocks as documented below.

* `scm` - (Optional) One or more `scm` blocks as documented below.
Expand All @@ -122,7 +124,7 @@ A `identity` block supports the following:

---

A `management`, `portal` and `scm` block supports the following:
A `management`, `portal`, `developer_portal` and `scm` block supports the following:

* `host_name` - (Required) The Hostname to use for the Management API.

Expand Down