Skip to content

Commit

Permalink
fix app gateway check for rewrite_rule block (#28011)
Browse files Browse the repository at this point in the history
  • Loading branch information
teowa authored Nov 21, 2024
1 parent ab63347 commit 7b0f662
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/services/network/application_gateway_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4725,9 +4725,17 @@ func checkBasicSkuFeatures(d *pluginsdk.ResourceDiff) error {
return fmt.Errorf("The Application Gateway does not support `trusted_client_certificate` blocks for the selected SKU tier %q", applicationgateways.ApplicationGatewaySkuNameBasic)
}

_, hasRewriteRuleSetConfig := d.GetOk("rewrite_rule_set")
rewriteRuleSet, hasRewriteRuleSetConfig := d.GetOk("rewrite_rule_set")
if hasRewriteRuleSetConfig {
return fmt.Errorf("The Application Gateway does not support `rewrite_rule_set` blocks for the selected SKU tier %q", applicationgateways.ApplicationGatewaySkuNameBasic)
for _, ruleSet := range rewriteRuleSet.([]interface{}) {
rs := ruleSet.(map[string]interface{})
for _, rule := range rs["rewrite_rule"].([]interface{}) {
r := rule.(map[string]interface{})
if len(r["url"].([]interface{})) > 0 {
return fmt.Errorf("The Application Gateway does not support `url` inside the `rewrite_rule` blocks for the selected SKU tier %q", applicationgateways.ApplicationGatewaySkuNameBasic)
}
}
}
}

return nil
Expand Down
12 changes: 12 additions & 0 deletions internal/services/network/application_gateway_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,18 @@ resource "azurerm_application_gateway" "test" {
backend_address_pool_name = local.backend_address_pool_name
backend_http_settings_name = local.http_setting_name
}
rewrite_rule_set {
name = "add_headers_for_signin"
rewrite_rule {
name = "SetHeaders"
rule_sequence = 100
request_header_configuration {
header_name = "X-Forwarded-Prefix"
header_value = "/adminportal"
}
}
}
}
`, r.template(data), data.RandomInteger)
}
Expand Down

0 comments on commit 7b0f662

Please sign in to comment.