how to make this work on the terraform configuration yml file?
in the document of terraform provider azure.there is just only a simple example.some complex scenarios are not covered at all.
We are facing the same issue as well. We are not able to define condition-based URL rewrite rule.
Could not find any example as well.
Same error here. June 2021. Itâs not possible to create a rewrite rule for the application gateway on Azure through Terraform.
I tried the following code:
rewrite_rule_set {
name = var.rewrite_rule_set_name
dynamic ârewrite_ruleâ {
iterator = rw_rule
for_each = var.rewrite_rules
content {
name = rw_rule.value.name
rule_sequence = rw_rule.value.rule_sequence
condition{
ignore_case = rw_rule.value.ignore_case
negate = rw_rule.value.negate
pattern = rw_rule.value.pattern
variable = rw_rule.value.variable
}
}
}
and included the rewrite_rule_set_name in my path rules.
Using âterraform applyâ, I get this error:
Error: Error Creating/Updating Application Gateway â[gatewayname]â: network.ApplicationGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=400 â Original Error: Code=âApplicationGatewayRewriteRuleSetActionSetInRewriteRuleCannotBeEmptyâ Message=âActionSet is a required field in a RewriteRule.â Details=
Unfortunately⌠creating the action_set{} section in the rewrite_rule_set doesnât solve the issue, since Terraform doesnât recognise it.
terraform version 0.14.0
Hi,
I hope you made it by now.
For anyone looking for a way to use rewrite rules via Terraform, feel free to include my example in your Azure application gatewayâs definition:
rewrite_rule_set {
name = "Rewrite-Rule-Set-Name"
rewrite_rule {
name = "First rule"
rule_sequence = 100
condition{
ignore_case = true
negate = false
pattern = ".*/*-service/(.*)"
variable = "var_uri_path"
}
url{
path = "{var_uri_path_1}"
reroute = false
query_string = null # using this we configure a rule that checks only the URL path, not both URL path and query string
}
}
rewrite_rule {
name = "Second rule"
rule_sequence = 100
condition{
ignore_case = true
negate = false
pattern = ".*/*-client/(.*)"
variable = "var_uri_path"
}
url{
path = "{var_uri_path_1}"
reroute = false
query_string = null # using this we configure a rule that checks only the URL path, not both URL path and query string
}
}
}