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_web_application_firewall_policy add enabled / disabled state for Custom Rules #23163

Merged
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 @@ -76,6 +76,11 @@ func resourceWebApplicationFirewallPolicy() *pluginsdk.Resource {
string(webapplicationfirewallpolicies.WebApplicationFirewallActionLog),
}, false),
},
"enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
},
"match_conditions": {
Type: pluginsdk.TypeList,
Required: true,
Expand Down Expand Up @@ -599,7 +604,13 @@ func expandWebApplicationFirewallPolicyWebApplicationFirewallCustomRule(input []
matchConditions := v["match_conditions"].([]interface{})
action := v["action"].(string)

enabled := webapplicationfirewallpolicies.WebApplicationFirewallStateEnabled
if value, ok := v["enabled"].(bool); ok && !value {
enabled = webapplicationfirewallpolicies.WebApplicationFirewallStateDisabled
}

result := webapplicationfirewallpolicies.WebApplicationFirewallCustomRule{
State: pointer.To(enabled),
Action: webapplicationfirewallpolicies.WebApplicationFirewallAction(action),
MatchConditions: expandWebApplicationFirewallPolicyMatchCondition(matchConditions),
Name: pointer.To(name),
Expand Down Expand Up @@ -946,6 +957,7 @@ func flattenWebApplicationFirewallPolicyWebApplicationFirewallCustomRule(input *
v["name"] = *name
}
v["action"] = string(item.Action)
v["enabled"] = pointer.From(item.State) == webapplicationfirewallpolicies.WebApplicationFirewallStateEnabled
v["match_conditions"] = flattenWebApplicationFirewallPolicyMatchCondition(item.MatchConditions)
v["priority"] = int(item.Priority)
v["rule_type"] = string(item.RuleType)
Expand Down
Loading