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 - fix check for the rewrite_rule block when using the Basic SKU. #28011

Merged
merged 1 commit into from
Nov 21, 2024
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
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
Loading