-
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
resource/cloudflare_ruleset: fix various attributes #2511
resource/cloudflare_ruleset: fix various attributes #2511
Conversation
changelog detected ✅ |
26b2e0a
to
b5e8c93
Compare
we'll also need to add the newly computed fields to https://github.com/zakcutner/terraform-provider-cloudflare/blob/0f6d5c7d0611c27116fbc0fee96cc3388d76c669/internal/framework/service/rulesets/resource.go#L1341 so that they aren't a part of the hash. |
These attributes are solely computed by the Rulesets API and so should never be set by users of the API. Having these as `Optional` attributes implied that users had control over them. This was particularly confusing because they were being populated by `cf-terraforming`, since they were marked as `Optional`. Also populate the last updated attribute from API responses.
If users do not set this attribute, it is computed by the Ruleset API (it will be set to the same value as the rule's ID).
Add the `stringplanmodifier.RequiresReplace()` modifier since this attribute cannot be changed without re-creating the ruleset. Also populate this attribute in API requests and from API responses.
0f6d5c7
to
5e93bae
Compare
Thanks for pointing me to this! I've updated the way it works a little in 1b4d844. The important change (in addition to the one you mentioned) is to ensure that setting the ref manually causes you to be "opted out" of this remapping. |
Also, I wanted to ask if you would recommend adding a state migration for the breaking change to make the |
5e93bae
to
34c2d5b
Compare
This is safe because all rules have a ref, as it defaults to the ID if it is not explicitly set. The advantage of using refs is that we can take into account whether the user has explicitly set the ref themselves. If they have, then we avoid changing it, or using that ref for other rules.
Use the `skip` action, rather than the `allow` action. The `allow` action does not exist in Rulesets, and only existed in Firewall Rules. Make the Origin Rules tests agnostic of the zone they are run with. Add `(cf.zone.plan eq "ENT")` to the expression of account-level WAF rulesets, as this is a new requirement. Also add the `stringplanmodifier.UseStateForUnknown()` modifier to the description attribute for rules, since this should never change when it is computed.
34c2d5b
to
603399f
Compare
as we discussed, i don't think we need this given the hoops folks would have had to jump through to get |
acceptance tests all looking good
|
This functionality has been released in v4.8.0 of the Terraform Cloudflare Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Make some minor fixes to the Rulesets acceptance resource tests
Use the
skip
action, rather than theallow
action. Theallow
action does not exist in Rulesets, and only existed in Firewall Rules.
Make the Origin Rules tests agnostic of the zone they are run with.
Add
(cf.zone.plan eq "ENT")
to the expression of account-level WAFrulesets, as this is a new requirement.
Also add the
stringplanmodifier.UseStateForUnknown()
modifier to thedescription attribute for rules, since this should never change when
it is computed.
Update preservation of rules to use refs rather than IDs
This is safe because all rules have a ref, as it defaults to the ID if
it is not explicitly set. The advantage of using refs is that we can
take into account whether the user has explicitly set the ref
themselves. If they have, then we avoid changing it, or using that ref
for other rules.
Fix ruleset rule shareable entitlement name attribute
Add the
stringplanmodifier.RequiresReplace()
modifier since thisattribute cannot be changed without re-creating the ruleset.
Also populate this attribute in API requests and from API responses.
Mark ruleset rule ref attribute as
Computed
If users do not set this attribute, it is computed by the Ruleset API
(it will be set to the same value as the rule's ID).
Prevent ruleset rule ID, version and last updated attributes being set
These attributes are solely computed by the Rulesets API and so should
never be set by users of the API. Having these as
Optional
attributesimplied that users had control over them.
This was particularly confusing because they were being populated by
cf-terraforming
, since they were marked asOptional
.Also populate the last updated attribute from API responses.
Fix typo in
semaphoreErr
variable name