Terraform custom_rule expression fails when using variable

I am trying to put cookie values into variables and then reference them in custom rule expressions, and it is failing badly. Cloudflare provider 3.35

rules {
    action = "skip"
    action_parameters {
      ruleset = "current"
      phases = [
        "http_ratelimit",
      ]
    }
    expression  = "(http.cookie eq var.cookie_dev) or (http.cookie eq var.cookie_smoketest)"
    description = "dev and smoketest Cookie Bypass"
    enabled     = true

I continually see errors like this one -

│ Error: error updating ruleset with ID "382aa4d0c2954f499c97ba5d07e31de1": '(http.cookie contains var.cookie_dev) or (http.cookie contains var.cookie_smoketest)' is not a valid value for expression because the expression is invalid: Filter parsing error (1:23):
│ (http.cookie contains var.q_local_dev) or (http.cookie contains var.q_smoketest)
│                                  ^^ invalid digit found in string while parsing with radix 16

I’ve tried various combinations of syntax here and always it fails. Has anyone got this working? Or is this just impossible?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.