diff --git a/azurerm/internal/services/network/resource_arm_application_gateway.go b/azurerm/internal/services/network/resource_arm_application_gateway.go index 8a23ebefcd0dc..3f725e51e456d 100644 --- a/azurerm/internal/services/network/resource_arm_application_gateway.go +++ b/azurerm/internal/services/network/resource_arm_application_gateway.go @@ -71,6 +71,7 @@ func resourceArmApplicationGateway() *schema.Resource { Required: true, ForceNew: true, }, + "identity": { Type: schema.TypeList, Optional: true, @@ -102,7 +103,7 @@ func resourceArmApplicationGateway() *schema.Resource { // Required "backend_address_pool": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -139,7 +140,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "backend_http_settings": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, MinItems: 1, Elem: &schema.Resource{ @@ -204,7 +205,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "authentication_certificate": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -269,7 +270,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "frontend_ip_configuration": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, MinItems: 1, Elem: &schema.Resource{ @@ -366,7 +367,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "http_listener": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -430,7 +431,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "custom_error_configuration": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -460,7 +461,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "request_routing_rule": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, MinItems: 1, Elem: &schema.Resource{ @@ -551,7 +552,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "redirect_configuration": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -608,6 +609,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, }, }, + "autoscale_configuration": { Type: schema.TypeList, Optional: true, @@ -627,6 +629,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, }, }, + "sku": { Type: schema.TypeList, Required: true, @@ -670,7 +673,7 @@ func resourceArmApplicationGateway() *schema.Resource { // Optional "authentication_certificate": { - Type: schema.TypeList, // todo this should probably be a map + Type: schema.TypeSet, // todo this should probably be a map Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -696,7 +699,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "trusted_root_certificate": { - Type: schema.TypeList, // todo this should probably be a map + Type: schema.TypeSet, // todo this should probably be a map Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -789,7 +792,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "probe": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -877,7 +880,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "rewrite_rule_set": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -977,8 +980,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "ssl_certificate": { - // TODO: should this become a Set? - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -1020,7 +1022,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "url_path_map": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -1052,7 +1054,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "path_rule": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -1283,7 +1285,7 @@ func resourceArmApplicationGateway() *schema.Resource { }, "custom_error_configuration": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -1348,7 +1350,7 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte gatewayIDFmt := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s" gatewayID := fmt.Sprintf(gatewayIDFmt, armClient.Account.SubscriptionId, resGroup, name) - trustedRootCertificates := expandApplicationGatewayTrustedRootCertificates(d.Get("trusted_root_certificate").([]interface{})) + trustedRootCertificates := expandApplicationGatewayTrustedRootCertificates(d.Get("trusted_root_certificate").(*schema.Set).List()) requestRoutingRules, err := expandApplicationGatewayRequestRoutingRules(d, gatewayID) if err != nil { @@ -1379,9 +1381,9 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte Tags: tags.Expand(t), ApplicationGatewayPropertiesFormat: &network.ApplicationGatewayPropertiesFormat{ AutoscaleConfiguration: expandApplicationGatewayAutoscaleConfiguration(d), - AuthenticationCertificates: expandApplicationGatewayAuthenticationCertificates(d.Get("authentication_certificate").([]interface{})), + AuthenticationCertificates: expandApplicationGatewayAuthenticationCertificates(d.Get("authentication_certificate").(*schema.Set).List()), TrustedRootCertificates: trustedRootCertificates, - CustomErrorConfigurations: expandApplicationGatewayCustomErrorConfigurations(d.Get("custom_error_configuration").([]interface{})), + CustomErrorConfigurations: expandApplicationGatewayCustomErrorConfigurations(d.Get("custom_error_configuration").(*schema.Set).List()), BackendAddressPools: expandApplicationGatewayBackendAddressPools(d), BackendHTTPSettingsCollection: expandApplicationGatewayBackendHTTPSettings(d, gatewayID), EnableHTTP2: utils.Bool(enablehttp2), @@ -1747,7 +1749,7 @@ func flattenApplicationGatewayAuthenticationCertificates(certs *[]network.Applic // since the certificate data isn't returned lets load any existing data nameToDataMap := map[string]string{} if existing, ok := d.GetOk("authentication_certificate"); ok && existing != nil { - for _, c := range existing.([]interface{}) { + for _, c := range existing.(*schema.Set).List() { b := c.(map[string]interface{}) nameToDataMap[b["name"].(string)] = b["data"].(string) } @@ -1784,7 +1786,7 @@ func flattenApplicationGatewayTrustedRootCertificates(certs *[]network.Applicati // since the certificate data isn't returned lets load any existing data nameToDataMap := map[string]string{} if existing, ok := d.GetOk("trusted_root_certificate"); ok && existing != nil { - for _, c := range existing.([]interface{}) { + for _, c := range existing.(*schema.Set).List() { b := c.(map[string]interface{}) nameToDataMap[b["name"].(string)] = b["data"].(string) } @@ -1821,7 +1823,7 @@ func flattenApplicationGatewayTrustedRootCertificates(certs *[]network.Applicati } func expandApplicationGatewayBackendAddressPools(d *schema.ResourceData) *[]network.ApplicationGatewayBackendAddressPool { - vs := d.Get("backend_address_pool").([]interface{}) + vs := d.Get("backend_address_pool").(*schema.Set).List() results := make([]network.ApplicationGatewayBackendAddressPool, 0) for _, raw := range vs { @@ -1896,7 +1898,7 @@ func flattenApplicationGatewayBackendAddressPools(input *[]network.ApplicationGa func expandApplicationGatewayBackendHTTPSettings(d *schema.ResourceData, gatewayID string) *[]network.ApplicationGatewayBackendHTTPSettings { results := make([]network.ApplicationGatewayBackendHTTPSettings, 0) - vs := d.Get("backend_http_settings").([]interface{}) + vs := d.Get("backend_http_settings").(*schema.Set).List() for _, raw := range vs { v := raw.(map[string]interface{}) @@ -1933,7 +1935,7 @@ func expandApplicationGatewayBackendHTTPSettings(d *schema.ResourceData, gateway } if v["authentication_certificate"] != nil { - authCerts := v["authentication_certificate"].([]interface{}) + authCerts := v["authentication_certificate"].(*schema.Set).List() authCertSubResources := make([]network.SubResource, 0) for _, rawAuthCert := range authCerts { @@ -2196,7 +2198,7 @@ func flattenApplicationGatewaySslPolicy(input *network.ApplicationGatewaySslPoli } func expandApplicationGatewayHTTPListeners(d *schema.ResourceData, gatewayID string) *[]network.ApplicationGatewayHTTPListener { - vs := d.Get("http_listener").([]interface{}) + vs := d.Get("http_listener").(*schema.Set).List() results := make([]network.ApplicationGatewayHTTPListener, 0) for _, raw := range vs { @@ -2211,7 +2213,7 @@ func expandApplicationGatewayHTTPListeners(d *schema.ResourceData, gatewayID str frontendIPConfigID := fmt.Sprintf("%s/frontendIPConfigurations/%s", gatewayID, frontendIPConfigName) frontendPortID := fmt.Sprintf("%s/frontendPorts/%s", gatewayID, frontendPortName) - customErrorConfigurations := expandApplicationGatewayCustomErrorConfigurations(v["custom_error_configuration"].([]interface{})) + customErrorConfigurations := expandApplicationGatewayCustomErrorConfigurations(v["custom_error_configuration"].(*schema.Set).List()) listener := network.ApplicationGatewayHTTPListener{ Name: utils.String(name), @@ -2455,7 +2457,7 @@ func flattenApplicationGatewayFrontendPorts(input *[]network.ApplicationGatewayF } func expandApplicationGatewayFrontendIPConfigurations(d *schema.ResourceData) *[]network.ApplicationGatewayFrontendIPConfiguration { - vs := d.Get("frontend_ip_configuration").([]interface{}) + vs := d.Get("frontend_ip_configuration").(*schema.Set).List() results := make([]network.ApplicationGatewayFrontendIPConfiguration, 0) for _, raw := range vs { @@ -2534,7 +2536,7 @@ func flattenApplicationGatewayFrontendIPConfigurations(input *[]network.Applicat } func expandApplicationGatewayProbes(d *schema.ResourceData) *[]network.ApplicationGatewayProbe { - vs := d.Get("probe").([]interface{}) + vs := d.Get("probe").(*schema.Set).List() results := make([]network.ApplicationGatewayProbe, 0) for _, raw := range vs { @@ -2662,7 +2664,7 @@ func flattenApplicationGatewayProbes(input *[]network.ApplicationGatewayProbe) [ } func expandApplicationGatewayRequestRoutingRules(d *schema.ResourceData, gatewayID string) (*[]network.ApplicationGatewayRequestRoutingRule, error) { - vs := d.Get("request_routing_rule").([]interface{}) + vs := d.Get("request_routing_rule").(*schema.Set).List() results := make([]network.ApplicationGatewayRequestRoutingRule, 0) for _, raw := range vs { @@ -2835,7 +2837,7 @@ func flattenApplicationGatewayRequestRoutingRules(input *[]network.ApplicationGa } func expandApplicationGatewayRewriteRuleSets(d *schema.ResourceData) *[]network.ApplicationGatewayRewriteRuleSet { - vs := d.Get("rewrite_rule_set").([]interface{}) + vs := d.Get("rewrite_rule_set").(*schema.Set).List() ruleSets := make([]network.ApplicationGatewayRewriteRuleSet, 0) for _, raw := range vs { @@ -3014,7 +3016,7 @@ func flattenApplicationGatewayRewriteRuleSets(input *[]network.ApplicationGatewa } func expandApplicationGatewayRedirectConfigurations(d *schema.ResourceData, gatewayID string) (*[]network.ApplicationGatewayRedirectConfiguration, error) { - vs := d.Get("redirect_configuration").([]interface{}) + vs := d.Get("redirect_configuration").(*schema.Set).List() results := make([]network.ApplicationGatewayRedirectConfiguration, 0) for _, raw := range vs { @@ -3181,7 +3183,7 @@ func flattenApplicationGatewaySku(input *network.ApplicationGatewaySku) []interf } func expandApplicationGatewaySslCertificates(d *schema.ResourceData) (*[]network.ApplicationGatewaySslCertificate, error) { - vs := d.Get("ssl_certificate").([]interface{}) + vs := d.Get("ssl_certificate").(*schema.Set).List() results := make([]network.ApplicationGatewaySslCertificate, 0) for _, raw := range vs { @@ -3257,7 +3259,7 @@ func flattenApplicationGatewaySslCertificates(input *[]network.ApplicationGatewa // since the certificate data isn't returned we have to load it from the same index if existing, ok := d.GetOk("ssl_certificate"); ok && existing != nil { - existingVals := existing.([]interface{}) + existingVals := existing.(*schema.Set).List() for _, existingVal := range existingVals { existingCerts := existingVal.(map[string]interface{}) existingName := existingCerts["name"].(string) @@ -3282,7 +3284,7 @@ func flattenApplicationGatewaySslCertificates(input *[]network.ApplicationGatewa } func expandApplicationGatewayURLPathMaps(d *schema.ResourceData, gatewayID string) (*[]network.ApplicationGatewayURLPathMap, error) { - vs := d.Get("url_path_map").([]interface{}) + vs := d.Get("url_path_map").(*schema.Set).List() results := make([]network.ApplicationGatewayURLPathMap, 0) for _, raw := range vs { @@ -3291,7 +3293,7 @@ func expandApplicationGatewayURLPathMaps(d *schema.ResourceData, gatewayID strin name := v["name"].(string) pathRules := make([]network.ApplicationGatewayPathRule, 0) - for _, ruleConfig := range v["path_rule"].([]interface{}) { + for _, ruleConfig := range v["path_rule"].(*schema.Set).List() { ruleConfigMap := ruleConfig.(map[string]interface{}) ruleName := ruleConfigMap["name"].(string)