diff --git a/azurerm/internal/services/network/resource_arm_web_application_firewall_policy.go b/azurerm/internal/services/network/resource_arm_web_application_firewall_policy.go index b5ca75fbe442d..49ab29d02ee24 100644 --- a/azurerm/internal/services/network/resource_arm_web_application_firewall_policy.go +++ b/azurerm/internal/services/network/resource_arm_web_application_firewall_policy.go @@ -49,7 +49,7 @@ func resourceArmWebApplicationFirewallPolicy() *schema.Resource { "resource_group_name": azure.SchemaResourceGroupNameDiffSuppress(), - "custom_rules": { + "custom_rule": { Type: schema.TypeList, Optional: true, Elem: &schema.Resource{ @@ -63,7 +63,7 @@ func resourceArmWebApplicationFirewallPolicy() *schema.Resource { string(network.WebApplicationFirewallActionLog), }, false), }, - "match_conditions": { + "match_condition": { Type: schema.TypeList, Required: true, Elem: &schema.Resource{ @@ -75,7 +75,7 @@ func resourceArmWebApplicationFirewallPolicy() *schema.Resource { Type: schema.TypeString, }, }, - "match_variables": { + "match_variable": { Type: schema.TypeList, Required: true, Elem: &schema.Resource{ @@ -276,7 +276,7 @@ func resourceArmWebApplicationFirewallPolicyCreateUpdate(d *schema.ResourceData, } location := azure.NormalizeLocation(d.Get("location").(string)) - customRules := d.Get("custom_rules").([]interface{}) + customRules := d.Get("custom_rule").([]interface{}) policySettings := d.Get("policy_settings").([]interface{}) managedRules := d.Get("managed_rules").([]interface{}) t := d.Get("tags").(map[string]interface{}) @@ -335,11 +335,14 @@ func resourceArmWebApplicationFirewallPolicyRead(d *schema.ResourceData, meta in d.Set("location", azure.NormalizeLocation(*location)) } if webApplicationFirewallPolicyPropertiesFormat := resp.WebApplicationFirewallPolicyPropertiesFormat; webApplicationFirewallPolicyPropertiesFormat != nil { - if err := d.Set("custom_rules", flattenArmWebApplicationFirewallPolicyWebApplicationFirewallCustomRule(webApplicationFirewallPolicyPropertiesFormat.CustomRules)); err != nil { + if err := d.Set("custom_rule", flattenArmWebApplicationFirewallPolicyWebApplicationFirewallCustomRule(webApplicationFirewallPolicyPropertiesFormat.CustomRules)); err != nil { return fmt.Errorf("Error setting `custom_rules`: %+v", err) } if err := d.Set("policy_settings", flattenArmWebApplicationFirewallPolicyPolicySettings(webApplicationFirewallPolicyPropertiesFormat.PolicySettings)); err != nil { - return fmt.Errorf("Error setting `policy_settings`: %+v", err) + return fmt.Errorf("Error setting `policy_setting`: %+v", err) + } + if err := d.Set("managed_rules", flattenArmWebApplicationFirewallPolicyManagedRulesDefinition(webApplicationFirewallPolicyPropertiesFormat.ManagedRules)); err != nil { + return fmt.Errorf("Error setting `managed_rule`: %+v", err) } if err := d.Set("managed_rules", flattenArmWebApplicationFirewallPolicyManagedRulesDefinition(webApplicationFirewallPolicyPropertiesFormat.ManagedRules)); err != nil { return fmt.Errorf("Error setting `managed_rules`: %+v", err) @@ -385,7 +388,7 @@ func expandArmWebApplicationFirewallPolicyWebApplicationFirewallCustomRule(input name := v["name"].(string) priority := v["priority"].(int) ruleType := v["rule_type"].(string) - matchConditions := v["match_conditions"].([]interface{}) + matchConditions := v["match_condition"].([]interface{}) action := v["action"].(string) result := network.WebApplicationFirewallCustomRule{ @@ -514,7 +517,7 @@ func expandArmWebApplicationFirewallPolicyMatchCondition(input []interface{}) *[ results := make([]network.MatchCondition, 0) for _, item := range input { v := item.(map[string]interface{}) - matchVariables := v["match_variables"].([]interface{}) + matchVariables := v["match_variable"].([]interface{}) operator := v["operator"].(string) negationCondition := v["negation_condition"].(bool) matchValues := v["match_values"].([]interface{}) @@ -561,7 +564,7 @@ func flattenArmWebApplicationFirewallPolicyWebApplicationFirewallCustomRule(inpu v["name"] = *name } v["action"] = string(item.Action) - v["match_conditions"] = flattenArmWebApplicationFirewallPolicyMatchCondition(item.MatchConditions) + v["match_condition"] = flattenArmWebApplicationFirewallPolicyMatchCondition(item.MatchConditions) if priority := item.Priority; priority != nil { v["priority"] = int(*priority) } @@ -686,7 +689,7 @@ func flattenArmWebApplicationFirewallPolicyMatchCondition(input *[]network.Match v := make(map[string]interface{}) v["match_values"] = utils.FlattenStringSlice(item.MatchValues) - v["match_variables"] = flattenArmWebApplicationFirewallPolicyMatchVariable(item.MatchVariables) + v["match_variable"] = flattenArmWebApplicationFirewallPolicyMatchVariable(item.MatchVariables) if negationCondition := item.NegationConditon; negationCondition != nil { v["negation_condition"] = *negationCondition }