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

Cloudflare snippet rules are sorted by the rules' descriptions #4788

Closed
3 tasks done
troymjones opened this issue Dec 17, 2024 · 3 comments
Closed
3 tasks done

Cloudflare snippet rules are sorted by the rules' descriptions #4788

troymjones opened this issue Dec 17, 2024 · 3 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.

Comments

@troymjones
Copy link
Contributor

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.10.2
on darwin_arm64

  • provider registry.terraform.io/cloudflare/cloudflare v4.48.0

Affected resource(s)

cloudflare_snippet_rules

Terraform configuration files

resource "cloudflare_snippet" "snippet_robots" {
    zone_id = cloudflare_zone.zone["indeedflex.com"].id
    name    = "robots"
    files {
        name    = "robots.js"
        content = file("../snippets/robots.js")
    }
    main_module = "robots.js"
}

resource "cloudflare_snippet" "snippet_sitemap" {
    zone_id = cloudflare_zone.zone["indeedflex.com"].id
    name    = "sitemap"
    files {
        name    = "sitemap.js"
        content = file("../snippets/sitemap.js")
    }
    main_module = "sitemap.js"
}

resource "cloudflare_snippet" "snippet_redirect" {
    zone_id = cloudflare_zone.zone["indeedflex.com"].id
    name    = "redirect"
    files {
        name    = "redirect.js"
        content = file("../snippets/redirect.js")
    }
    main_module = "redirect.js"
  
}

resource "cloudflare_snippet" "snippet_lowercase" {
    zone_id = cloudflare_zone.zone["indeedflex.com"].id
    name    = "lowercase"
    files {
        name    = "lowercase.js"
        content = file("../snippets/lowercase.js")
    }
    main_module = "lowercase.js"
}

resource "cloudflare_snippet_rules" "rules_indeedflex" {
    zone_id = cloudflare_zone.zone["indeedflex.com"].id

    rules {
        enabled      = true
        expression   = "http.request.uri.path matches \"^/sitemap.xml$\""
        description  = "Transform sitemap request - rule #1"
        snippet_name = cloudflare_snippet.snippet_sitemap.name
    }
    rules {
        enabled      = true
        expression   = "http.request.uri.path matches \"^/robots.txt$\""
        description  = "Custom robots.txt - rule #2"
        snippet_name = cloudflare_snippet.snippet_robots.name
    }
    rules {
        enabled     = true
        expression  = "http.request.uri.path matches \"^/badpath/redirect$\""
        description = "Redirect bad path - rule #3"
        snippet_name = cloudflare_snippet.snippet_redirect.name
    }
    rules {
        enabled     = true
        expression  = "http.request.uri.path matches \"^/lowercase$\""
        description = "all lowercase letters are sorted last - rule #4"
        snippet_name = cloudflare_snippet.snippet_lowercase.name
    }
}

Link to debug output

https://gist.github.com/troymjones/8e6d1f15560c18d70390569dac1f0b0e

Panic output

No response

Expected output

The resource should respect the order of the list of rules OR at the very least provide a way to set a priority/order number. The only current way to do this dynamically that makes sense is to pad a number with zeros (due to lexicographical sorting) and prepend that to every description based upon the order.

Actual output

List of rules was reordered based upon the lexicographical sorting of the description for each rule.

Steps to reproduce

See terraform configuration files for an example.

  1. Add multiple snippets to a single zone
  2. Reference those snippets in respective rules for the zone
  3. Change the description to be out of order from the presented order of rules
  4. Notice that on a plan/apply, the order of rules has changed to be alphabetically sorted based upon the rule description.

Additional factoids

No response

References

No response

@troymjones troymjones added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 17, 2024
Copy link
Contributor

Terraform debug log detected ✅

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label Dec 17, 2024
Copy link
Contributor

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@jacobbednarz
Copy link
Member

this isn't something we can control in the provider, sorry! you're best bet is to drop in a support ticket and have it routed to the correct team -- right now it is a set which is not ordered.

@jacobbednarz jacobbednarz closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.
Projects
None yet
Development

No branches or pull requests

2 participants