You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Page rule should be created with an action of browser_cache_ttl and a value of 0 (respect cache control headers for Enterprise users)
Actual Behavior
Page rule was not created and Terraform threw an error that actions cannot be empty which is enforced by the schema.
Steps to Reproduce
Use a Clouflare Enterprise account
terraform apply
Important Factoids
This is only an issue for Enterprise users who want to initially set the browser_cache_ttl to 0. It is not an issue if you initially set to 1 an then to 0 (this is also the workaround available if you're currently impacted).
Further information
From debugging this issue extensively in #338, the issue boils down to the fact that we are using a zero value for both the inactive state and an a desirable value. This causes an issue whereby the Terraform state ends up thinking that the configuration doesn't have any changes and it shouldn't include the action.browser_cache_ttl in the payload.
I tried a couple of methods to force this into working:
Swap to using TypeString as the schema type. This would address the issue because the default value would be "" instead of "0". The resource is then updated to cast it as an integer where needed. Some parts of page_rules: Make cache TTLs behave sensibly #334 show how this would work. I didn't end up going forward with this as there was a better way of solving the particular issue (not just this one).
Use HasChange to determine the old and new values. This didn't end up working because the old and new values were always the same and couldn't be differentiated. I tried combining it with GetOkExists however encountered the same problem where the default was always being set so it was always coming back as not changing.
The text was updated successfully, but these errors were encountered:
jacobbednarz
changed the title
browser_cache_ttl canot initially be zerobrowser_cache_ttl cannot initially be zero
May 12, 2019
Terraform Version
Affected Resource(s)
cloudflare_page_rule
Terraform Configuration Files
Expected Behavior
Page rule should be created with an action of
browser_cache_ttl
and a value of 0 (respect cache control headers for Enterprise users)Actual Behavior
Page rule was not created and Terraform threw an error that
actions
cannot be empty which is enforced by the schema.Steps to Reproduce
terraform apply
Important Factoids
This is only an issue for Enterprise users who want to initially set the
browser_cache_ttl
to 0. It is not an issue if you initially set to 1 an then to 0 (this is also the workaround available if you're currently impacted).Further information
From debugging this issue extensively in #338, the issue boils down to the fact that we are using a zero value for both the inactive state and an a desirable value. This causes an issue whereby the Terraform state ends up thinking that the configuration doesn't have any changes and it shouldn't include the
action.browser_cache_ttl
in the payload.I tried a couple of methods to force this into working:
TypeString
as the schema type. This would address the issue because the default value would be""
instead of"0"
. The resource is then updated to cast it as an integer where needed. Some parts of page_rules: Make cache TTLs behave sensibly #334 show how this would work. I didn't end up going forward with this as there was a better way of solving the particular issue (not just this one).HasChange
to determine the old and new values. This didn't end up working because the old and new values were always the same and couldn't be differentiated. I tried combining it withGetOkExists
however encountered the same problem where the default was always being set so it was always coming back as not changing.The text was updated successfully, but these errors were encountered: