cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
779 stars 600 forks source link

.rules[0].logging: block count changed from 0 to 1. #4442

Open VarshneyPrince opened 3 days ago

VarshneyPrince commented 3 days ago

Confirmation

Terraform and Cloudflare provider version

latest 4.44.0

Affected resource(s)

cloudflare_ruleset

Terraform configuration files

resource "cloudflare_ruleset" "zone_custom_firewall_rules" {
  zone_id     = data.cloudflare_zone.zone_id.id
  name        = "tf-mid-global-custom-firewall-rules"
  description = "tf-mid-global-custom-firewall-rules"
  kind        = "zone"
  phase       = "http_request_firewall_custom"

  dynamic "rules" {
    for_each = var.AUTH_HEADERS_EXEMPTION
    iterator = prod_auth_header_rules
    content {
      action = "skip"
      action_parameters {
        phases = ["http_ratelimit"]
      }
      expression  = replace(local.exempt_auth_header_expression, "{AUTH_HEADER}", prod_auth_header_rules.value)
      description = "tf-mid-skip-auth-header-${prod_auth_header_rules.key}"

    }
  }
}

Link to debug output

https://gist.github.com/VarshneyPrince/0796ef47344fd97e955da36b860e400d

Panic output

Error: Provider produced inconsistent result after apply When applying changes to module.cloudflare-rules-module.cloudflare_ruleset.zone_custom_firewall_rules, provider "module.cloudflare-rules-module.provider[\"registry.terraform.io/cloudflare/cloudflare\"]" produced an unexpected new value: .rules[0].logging: block count changed from 0 to 1.

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

Expected output

Resource gets created without any error.

Actual output

Resource gets created but with error.

Error: Provider produced inconsistent result after apply When applying changes to module.cloudflare-rules-module.cloudflare_ruleset.zone_custom_firewall_rules, provider "module.cloudflare-rules-module.provider[\"registry.terraform.io/cloudflare/cloudflare\"]" produced an unexpected new value: .rules[0].logging: block count changed from 0 to 1.

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

Steps to reproduce

  1. Add this cloudflare_ruleset resource
  2. Add multiple dynamic firewall rules
  3. tf apply

Additional factoids

No response

References

No response

github-actions[bot] commented 3 days ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

github-actions[bot] commented 3 days ago

Thank you for reporting this issue! For maintainers to dig into issues it is required that all issues include the entirety of TF_LOG=DEBUG output to be provided. The only parts that should be redacted are your user credentials in the X-Auth-Key, X-Auth-Email and Authorization HTTP headers. Details such as zone or account identifiers are not considered sensitive but can be redacted if you are very cautious. This log file provides additional context from Terraform, the provider and the Cloudflare API that helps in debugging issues. Without it, maintainers are very limited in what they can do and may hamper diagnosis efforts.

This issue has been marked with triage/needs-information and is unlikely to receive maintainer attention until the log file is provided making this a complete bug report.

VarshneyPrince commented 3 days ago

Already added the information there.

github-actions[bot] commented 2 days ago

Thank you for opening this issue and sorry to hear you're hitting issues. Unfortunately, the reproduction case provided contains HCL dynamic expressions. Examples of these are:

Maintainers don't accept these as reproduction cases since using these constructs and expressions can hold their own logic bugs which are outside of the provider and not able to be diagnosed.

For maintainers to triage this issue, we recommend providing a minimal reproduction test case that is only contains the impacted resources and can be easily reproduced in an isolated environment. Without providing this, maintainers are limited in what support they can provide.