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_application_gateway - support priority property #13498

Merged
merged 7 commits into from
Oct 28, 2021
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
25 changes: 25 additions & 0 deletions internal/services/network/application_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,12 @@ func resourceApplicationGateway() *pluginsdk.Resource {
ValidateFunc: validation.StringIsNotEmpty,
},

"priority": {
Type: pluginsdk.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(1, 20000),
},

"backend_address_pool_id": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -2869,6 +2875,7 @@ func flattenApplicationGatewayProbes(input *[]network.ApplicationGatewayProbe) [
func expandApplicationGatewayRequestRoutingRules(d *pluginsdk.ResourceData, gatewayID string) (*[]network.ApplicationGatewayRequestRoutingRule, error) {
vs := d.Get("request_routing_rule").(*pluginsdk.Set).List()
results := make([]network.ApplicationGatewayRequestRoutingRule, 0)
priorityset := false

for _, raw := range vs {
v := raw.(map[string]interface{})
Expand All @@ -2880,6 +2887,7 @@ func expandApplicationGatewayRequestRoutingRules(d *pluginsdk.ResourceData, gate
backendAddressPoolName := v["backend_address_pool_name"].(string)
backendHTTPSettingsName := v["backend_http_settings_name"].(string)
redirectConfigName := v["redirect_configuration_name"].(string)
priority := int32(v["priority"].(int))

rule := network.ApplicationGatewayRequestRoutingRule{
Name: utils.String(name),
Expand Down Expand Up @@ -2934,9 +2942,22 @@ func expandApplicationGatewayRequestRoutingRules(d *pluginsdk.ResourceData, gate
}
}

if priority != 0 {
rule.ApplicationGatewayRequestRoutingRulePropertiesFormat.Priority = &priority
priorityset = true
}

results = append(results, rule)
}

if priorityset {
for _, rule := range results {
if rule.ApplicationGatewayRequestRoutingRulePropertiesFormat.Priority == nil {
return nil, fmt.Errorf("If you wish to use rule priority, you will have to specify rule-priority field values for all the existing request routing rules.")
}
}
}

return &results, nil
}

Expand All @@ -2960,6 +2981,10 @@ func flattenApplicationGatewayRequestRoutingRules(input *[]network.ApplicationGa
output["name"] = *config.Name
}

if config.Priority != nil {
output["priority"] = *config.Priority
}

if pool := props.BackendAddressPool; pool != nil {
if pool.ID != nil {
poolId, err := azure.ParseAzureResourceID(*pool.ID)
Expand Down
Loading