How to specify an ActionSet in a RewriteRule for azurerm_application_gateway?

I get this error when trying to apply an Azure Application Gateway:

Error: Error Creating/Updating Application Gateway “X” (Resource Group “X”): network.ApplicationGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=400 – Original Error: Code=“ApplicationGatewayRewriteRuleSetActionSetInRewriteRuleCannotBeEmpty” Message=“ActionSet is a required field in a RewriteRule.” Details=

But in the module documentation there is nothing on ActionSets. I even did a terraform import on a live Application Gateway with Rewrite Rules and it would show any sort of Action or ActionSet block.

This is with both the 1.x and 2.x azurerm provider.

2 Likes

Did you find a solution to this?
I am having the same issue:

network.ApplicationGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=400 – Original
Error: Code=“ApplicationGatewayRewriteRuleSetActionSetInRewriteRuleCannotBeEmpty” Message=“ActionSet is a required field in a RewriteRule.” Details=

Sadly I did not find a solution and could not find a single example of using the Rewrite Rules.

Same error here. 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 the 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

I am willing to try using terraform apply -target X to avoid overriding the rewrite rules every time.

Hi everyone,

I wanted to highlight that it is now possible to achieve this.
Using:

  • Terraform version 1.3.2
  • azuread version 2.27.0
  • azurerm version 3.26.0

Example:

rewrite_rule_set {
    name = "ExampleRuleSet"

    rewrite_rule {
      name          = "Service rule"
      rule_sequence = 100

      condition{
        ignore_case = true
        negate      = false
        pattern     = ".*/*test/(.*)"
        variable    = "var_uri_path"
      }

      url{
        path         = "{var_uri_path_1}"
        reroute      = false
        components   = "path_only" # targeting the path only, not the query
      }
    }
}