-
Notifications
You must be signed in to change notification settings - Fork 632
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
Impossible to not have a drift with an empty cookie
block in cloudflare_page_rule
since 3.34.0
#2225
Comments
Community NoteVoting for Prioritization
Volunteering to Work on This Issue
|
cookie
block cloudflare_page_rule
since 3.34.0
cookie
block in cloudflare_page_rule
since 3.34.0
have you tried removing this field from your state file? i suspect this has something to do with it still being an empty value and trying to keep it in sync. |
this relies on a module too which may make this harder to diagnose as it doesn't happen on a fresh or minimal repro. |
It's a good idea, I just did 2 ways: Doing a
This is a very simple internal module, I'm touching the resource directly to do my tests. I think I nailed down the problem: If I don't state a cookie block at all:
I get no drift:
Lead to:
or
Lead to:
This one is weird, it wants to set an empty object There is something fishy here. The big problem is that with those nested objects ( |
I think this was me here: #2208 |
@irA I'm not so sure why the provider doesn't remove these empty cookie fields altogether, I was looking at the code, but I wasn't able to figure it out YET. These should be completely removed by the provider, but they are not.
Is it a viable workaround if you remove these empty cookie fields / cookie fields with empty arrays from your configuration? |
For a single resource yes but: Sadly not for a module that optionally propose to set cookie settings, AFAIK there is no way in a dynamic BTW, this same problem seem to apply to all optional blocks within |
if this is for a module, it very well could be the module causing the issue which involves its own logic for when to set or define these fields. for now, I'd suggest coming up with a minimal reproduction case without modules or dynamics that demonstrates the bug. as it stands, this isn't reproducible using just the resource so I'm hesitant to say this is a bug in the provider until we can rule those out. |
Again, the module has nothing to do with it, I was editing the resource directly. Anyway, here's a self-contained explicit exhaustive reproductive case. You'll only have to change the zone_id: terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
}
}
}
provider "cloudflare" {
}
resource "cloudflare_page_rule" "this" {
target = "whatever/*"
zone_id = "82592f37298b1a37a3fb743431a53c1c"
actions {
cache_key_fields {
query_string {
exclude = ["api_token"]
}
user {
lang = true
}
host {}
cookie {}
}
}
} Run
Good.
And again:
etc... And yes if I don't specify any |
this is what #2208 removed the need for and the what you should be doing when you don't have configuration options for that. this has been a weird empty block since it's inception (and caused some internals issues) but has since been fixed to be correct. i'm sorry but this is an issue with the syntax used to make the resource dynamic. as such, we don't directly support it and I'd recommend you open a feature request with terraform core to achieve this. alternatively, you can migrate this functionality to the rulesets equivalent and use that resource instead. |
I understand, what confused me I guess is that the doc still states it's required but allowed to be empty. Same behavior for the We'll workaround it by adding more dynamic blocks. |
if the docs are adding confusion here, we can get those updated to reflect the true state now. you're welcome to send over a PR otherwise someone will get to it later on. |
Confirmation
Terraform and Cloudflare provider version
Terraform v1.3.7
on darwin_arm64
Affected resource(s)
Terraform configuration files
Link to debug output
https://gist.github.com/lra/5241499210278c1c1e8aca383529ebf3
Panic output
No response
Expected output
No changes. Your infrastructure matches the configuration.
Actual output
Steps to reproduce
cloudflare_page_rule.cache_key_fields
or define an empty cookie block, or define a block with empty array ascheck_presence
andinclude
, I tried everything I could.Additional factoids
This is not happening with
3.33.1
References
No response
The text was updated successfully, but these errors were encountered: