Skip to content

Commit

Permalink
Simplify "firewall_policy" subresource to "firewall_policy_id"
Browse files Browse the repository at this point in the history
Signed-off-by: Sune Keller <absukl@almbrand.dk>
  • Loading branch information
sirlatrom committed Mar 18, 2020
1 parent d86e20b commit cd7d32c
Showing 1 changed file with 12 additions and 30 deletions.
Expand Up @@ -1276,19 +1276,10 @@ func resourceArmApplicationGateway() *schema.Resource {
},
},

"firewall_policy": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Required: true,
ValidateFunc: azure.ValidateResourceID,
},
},
},
"firewall_policy_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: azure.ValidateResourceID,
},

"custom_error_configuration": {
Expand Down Expand Up @@ -1445,10 +1436,9 @@ func resourceArmApplicationGatewayCreateUpdate(d *schema.ResourceData, meta inte
gateway.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration = expandApplicationGatewayWafConfig(d)
}

if res, ok := d.GetOk("firewall_policy"); ok {
if res, ok := d.GetOk("firewall_policy_id"); ok {
vs := res.([]interface{})
v := vs[0].(map[string]interface{})
id := v["id"].(string)
id := vs[0].(string)
gateway.ApplicationGatewayPropertiesFormat.FirewallPolicy = &network.SubResource{
ID: &id,
}
Expand Down Expand Up @@ -1633,8 +1623,8 @@ func resourceArmApplicationGatewayRead(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error setting `waf_configuration`: %+v", setErr)
}

if setErr := d.Set("firewall_policy", flattenApplicationGatewayFirewallPolicy(props.FirewallPolicy)); setErr != nil {
return fmt.Errorf("Error setting `firewall_policy`: %+v", setErr)
if setErr := d.Set("firewall_policy_id", flattenApplicationGatewayFirewallPolicy(props.FirewallPolicy)); setErr != nil {
return fmt.Errorf("Error setting `firewall_policy_id`: %+v", setErr)
}
}

Expand Down Expand Up @@ -3619,22 +3609,14 @@ func flattenApplicationGatewayWafConfig(input *network.ApplicationGatewayWebAppl
return results
}

func flattenApplicationGatewayFirewallPolicy(input *network.SubResource) []interface{} {
results := make([]interface{}, 0)
if input == nil {
return results
}

output := make(map[string]interface{})
func flattenApplicationGatewayFirewallPolicy(input *network.SubResource) string {
output := ""

id := ""
if input.ID != nil {
id = *input.ID
output = *input.ID
}
output["id"] = id
results = append(results, output)

return results
return output
}

func expandApplicationGatewayFirewallDisabledRuleGroup(d []interface{}) *[]network.ApplicationGatewayFirewallDisabledRuleGroup {
Expand Down

0 comments on commit cd7d32c

Please sign in to comment.