-
Notifications
You must be signed in to change notification settings - Fork 630
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
Rate Limit plan invalid when correlate not set #256
Comments
Additional information. The And is required (or at least will never be Correlate RateLimitCorrelate `json:"correlate"` Workaround to make Terraform idempotent is an empty correlate in the tf file:
|
@sodabrew The reason it is showing up like that is because it's a
which translates to: correlate {
by = "nat"
} I'll have to do some more digging as I'm not seeing this with the test configurations. Did you previously have a broken correlate setting in your Terraform state file? Could you try removing the rate limit using |
There is also the |
Ok, so I've narrowed this down to the |
The most sensible approach I can come up with is the following: diff --git a/cloudflare/resource_cloudflare_rate_limit.go b/cloudflare/resource_cloudflare_rate_limit.go
index dfc531d..fc239b5 100644
--- a/cloudflare/resource_cloudflare_rate_limit.go
+++ b/cloudflare/resource_cloudflare_rate_limit.go
@@ -227,7 +227,10 @@ func resourceCloudflareRateLimitCreate(d *schema.ResourceData, meta interface{})
+ if rateLimit.Correlate != nil {
+ d.Set("correlate", flattenRateLimitCorrelate(*rateLimit.Correlate))
+ }
+
d.Set("description", rateLimit.Description)
d.Set("disabled", rateLimit.Disabled)
diff --git a/vendor/github.com/cloudflare/cloudflare-go/rate_limiting.go b/vendor/github.com/cloudflare/cloudflare-go/rate_limiting.go
index 253c44b..2b3690c 100644
--- a/vendor/github.com/cloudflare/cloudflare-go/rate_limiting.go
+++ b/vendor/github.com/cloudflare/cloudflare-go/rate_limiting.go
@@ -18,7 +18,7 @@ type RateLimit struct {
Threshold int `json:"threshold"`
Period int `json:"period"`
Action RateLimitAction `json:"action"`
- Correlate RateLimitCorrelate `json:"correlate"`
+ Correlate *RateLimitCorrelate `json:"correlate"`
}
// RateLimitTrafficMatcher contains the rules that will be used to apply a rate limit to traffic This does mean though, we'll need to address this in the underlying library first but it does cover all of our use cases and prevents the need to do weird things with the built in Terraform types. |
Have opened cloudflare/cloudflare-go#281 to get this addressed upstream and then I can fix it here too. |
This has landed so I'll be taking a pass at this in the coming days. |
We only want to set `rateLimit.Correlate` when it's required. This stops the value from continiously being updated in the Terraform state but not changed in the remote. Closes cloudflare#256
Awesome! Thanks! |
This file wasn't committed in cloudflare#246 so we can add it here to ensure everyone is on the same versions. Fixes cloudflare#256.
In version 1.12, since PR #204 was merged,
terraform plan
against a cloudflare_rate_limit stanza that does not havecorrelate
(it is listed as optional after all) and for which no correlate is set in the Console, always reports a pending change:Neither "1" nor "0" would seem to be valid values for correlate, given that
by = "nat"
is the only option shown in the provider docs - though I cannot even find the documentation for this feature - so I'm not sure what's a correct value here.The text was updated successfully, but these errors were encountered: