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_ruleset headers are wrongly sorted and result in an terraform exception #3487

Closed
3 tasks done
Cookiiiies opened this issue Jul 22, 2024 · 2 comments
Closed
3 tasks done
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

@Cookiiiies
Copy link

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.9.2
on darwin_amd64

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

Affected resource(s)

cloudflare_ruleset

Terraform configuration files

terraform {
  required_version = ">= 1.4"
  backend "local" {
  }
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "4.37.0"
    }
  }
}

variable "zone_id" {
  type = string
  default = "xxxx"
}
resource "cloudflare_ruleset" "response_header_remove_test" {
  zone_id     = var.zone_id
  name        = "Remove response headers"
  kind        = "zone"
  phase       = "http_response_headers_transform"

  rules {
    action      = "rewrite"
    description = "Remove response headers"
    enabled     = true
    expression  = "true"
    action_parameters {
      headers {
        name      = "aa_2"
        operation = "remove"
      }
      headers {
        name      = "xb_1"
        operation = "remove"
      }
      headers {
        name      = "xa_2"
        operation = "remove"
      }

    }
  }
}

Link to debug output

https://gist.github.com/Cookiiiies/b3c6c066046c6fa58611685e2e62edf7

Panic output

No response

Expected output

It seems like the sorting is not working as expected. If I put the header entries in alphabetically sorted order, the provider is working as expected. If I change the order the provider is failing.
So a "workaround" is to simple add headers the entries in a alphabetically order. Only tested for the phase http_response_headers_transform

Actual output


│ Error: Provider produced inconsistent result after apply

│ When applying changes to cloudflare_ruleset.response_header_remove_test, provider "provider["registry.terraform.io/cloudflare/cloudflare"]" produced an unexpected new value:
│ .rules[0].action_parameters[0].headers[1].name: was cty.StringVal("xb_1"), but now cty.StringVal("xa_2").

│ This is a bug in the provider, which should be reported in the provider's own issue tracker.


│ Error: Provider produced inconsistent result after apply

│ When applying changes to cloudflare_ruleset.response_header_remove_test, provider "provider["registry.terraform.io/cloudflare/cloudflare"]" produced an unexpected new value:
│ .rules[0].action_parameters[0].headers[2].name: was cty.StringVal("xa_2"), but now cty.StringVal("xb_1").

│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Steps to reproduce

  1. terraform init
  2. terraform apply
  3. -> should fail
  4. switch position of headers "xb_1" with "xa_1"
  5. terraform apply
  6. -> should work

Additional factoids

No response

References

No response

@Cookiiiies Cookiiiies 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 Jul 22, 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.

@github-actions github-actions bot added triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. labels Jul 22, 2024
@Cookiiiies
Copy link
Author

rtfm: https://registry.terraform.io/providers/cloudflare/cloudflare/4.29.0/docs/resources/ruleset#headers

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

1 participant