Skip to content
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

Page Rules bugfix / enhancements #61

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9c362a5
add resolve_override page_rule action
SteveGoldthorpe-Work May 15, 2018
4215d73
Merge pull request #2 from SteveGoldthorpe-WDFC/add-page-rule-resolve…
SteveGoldthorpe-Work May 15, 2018
1bd5f6a
add host_header_override page_rule action
SteveGoldthorpe-Work May 15, 2018
6c578de
add doc for resolve_override
SteveGoldthorpe-Work May 15, 2018
a143bdd
Merge branch 'testing' into add-page-rule-host_header_override
SteveGoldthorpe-Work May 15, 2018
8b9f728
Merge pull request #3 from SteveGoldthorpe-WDFC/add-page-rule-resolve…
SteveGoldthorpe-Work May 15, 2018
e5bc508
Merge branch 'testing' into add-page-rule-host_header_override
SteveGoldthorpe-Work May 15, 2018
e04425c
Merge pull request #4 from SteveGoldthorpe-WDFC/add-page-rule-host_he…
SteveGoldthorpe-Work May 15, 2018
6f63e36
missing bracket after merge conflict
SteveGoldthorpe-Work May 15, 2018
6a6fe25
Merge pull request #5 from SteveGoldthorpe-WDFC/add-page-rule-host_he…
SteveGoldthorpe-Work May 15, 2018
2984ddc
fix typo and go fmt
SteveGoldthorpe-Work May 15, 2018
d38ec12
go fmt
SteveGoldthorpe-Work May 15, 2018
7a91da4
Merge branch 'testing' into add-page-rule-resolve_override
SteveGoldthorpe-Work May 15, 2018
653a17a
Merge pull request #6 from SteveGoldthorpe-WDFC/add-page-rule-resolve…
SteveGoldthorpe-Work May 15, 2018
6635b10
Merge pull request #7 from SteveGoldthorpe-WDFC/add-page-rule-host_he…
SteveGoldthorpe-Work May 15, 2018
6f7d40a
add bypass_cache_on_cookie page_rule action
SteveGoldthorpe-Work May 15, 2018
c9ed559
restore automatic_https_rewrites comment
SteveGoldthorpe-Work May 15, 2018
e56ae80
Merge branch 'testing' into add-page-rule-bypass_cache_on_cookie
SteveGoldthorpe-Work May 15, 2018
42fa463
Merge pull request #8 from SteveGoldthorpe-WDFC/add-page-rule-bypass_…
SteveGoldthorpe-Work May 15, 2018
c9aeba9
page_rules status is active or disabled not paused
SteveGoldthorpe-Work May 15, 2018
354ee2b
Merge pull request #9 from SteveGoldthorpe-WDFC/fix-page-rule-disabled
SteveGoldthorpe-Work May 15, 2018
8c2f141
add waf page rule
SteveGoldthorpe-Work May 31, 2018
02e7302
Merge pull request #10 from SteveGoldthorpe-Work/add-page-rule-waf
SteveGoldthorpe-Work May 31, 2018
e8baece
add doc for waf page rule keyword
SteveGoldthorpe-Work May 31, 2018
bc26ab3
Merge pull request #11 from SteveGoldthorpe-Work/add-page-rule-waf
SteveGoldthorpe-Work May 31, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions cloudflare/resource_cloudflare_page_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ func resourceCloudFlarePageRule() *schema.Resource {
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"on", "off"}, false),
},
"waf": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"on", "off"}, false),
},
// end on/off fields

// unitary fields
Expand Down Expand Up @@ -127,6 +132,13 @@ func resourceCloudFlarePageRule() *schema.Resource {
ValidateFunc: validation.IntAtMost(31536000),
},

// maxlength 12 x 150 + 11 = 1811
"bypass_cache_on_cookie": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(1, 1811),
},

"edge_cache_ttl": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -161,6 +173,18 @@ func resourceCloudFlarePageRule() *schema.Resource {
},
},

"host_header_override": {
Type: schema.TypeString,
Optional: true,
},

// should really validate if FQDN is resolveable, non-empty and < domain length limit will have to do
"resolve_override": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(1, 255),
},

// may not be used with disable_performance
"rocket_loader": {
Type: schema.TypeString,
Expand Down Expand Up @@ -193,7 +217,7 @@ func resourceCloudFlarePageRule() *schema.Resource {
Type: schema.TypeString,
Default: "active",
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"active", "paused"}, false),
ValidateFunc: validation.StringInSlice([]string{"active", "disabled"}, false),
},
},
}
Expand Down Expand Up @@ -395,10 +419,10 @@ func resourceCloudFlarePageRuleDelete(d *schema.ResourceData, meta interface{})
return nil
}

var pageRuleAPIOnOffFields = []string{"always_online", "automatic_https_rewrites", "browser_check", "email_obfuscation", "ip_geolocation", "opportunistic_encryption", "server_side_exclude", "smart_errors"}
var pageRuleAPIOnOffFields = []string{"always_online", "automatic_https_rewrites", "browser_check", "email_obfuscation", "ip_geolocation", "opportunistic_encryption", "server_side_exclude", "smart_errors", "waf"}
var pageRuleAPINilFields = []string{"always_use_https", "disable_apps", "disable_performance", "disable_security"}
var pageRuleAPIFloatFields = []string{"browser_cache_ttl", "edge_cache_ttl"}
var pageRuleAPIStringFields = []string{"cache_level", "rocket_loader", "security_level", "ssl"}
var pageRuleAPIStringFields = []string{"bypass_cache_on_cookie", "cache_level", "host_header_override", "resolve_override", "rocket_loader", "security_level", "ssl"}

func transformFromCloudFlarePageRuleAction(pageRuleAction *cloudflare.PageRuleAction) (key string, value interface{}, err error) {
key = pageRuleAction.ID
Expand Down
8 changes: 6 additions & 2 deletions website/docs/r/page_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The following arguments are supported:
* `target` - (Required) The URL pattern to target with the page rule.
* `actions` - (Required) The actions taken by the page rule, options given below.
* `priority` - (Optional) The priority of the page rule among others for this target.
* `status` - (Optional) Whether the page rule is active or paused.
* `status` - (Optional) Whether the page rule is active or disabled.

Action blocks support the following:

Expand All @@ -51,12 +51,16 @@ Action blocks support the following:
* `disable_performance` - (Optional) Boolean of whether this action is enabled. Default: false.
* `disable_security` - (Optional) Boolean of whether this action is enabled. Default: false.
* `browser_cache_ttl` - (Optional) The Time To Live for the browser cache.
* `bypass_cache_on_cookie` - (Optional) Disable the cache on cookie regex match.
* `edge_cache_ttl` - (Optional) The Time To Live for the edge cache.
* `cache_level` - (Optional) Whether to set the cache level to `"byypass"`, `"basic"`, `"simplified"`, `"aggressive"`, or `"cache_everything"`.
* `forwarding_url` - (Optional) The URL to forward to, and with what status. See below.
* `host_header_override` - (Optional) The Host Header to override on the origin servers.
* `resolve_override` - (Optional) Override the origin server with this host.
* `rocket_loader` - (Optional) Whether to set the rocket loader to `"off"`, `"manual"`, or `"automatic"`.
* `security_level` - (Optional) Whether to set the security level to `"essentially_off"`, `"low"`, `"medium"`, `"high"`, or `"under_attack"`.
* `ssl` - (Optional) Whether to set the SSL mode to `"off"`, `"flexible"`, `"full"`, or `"strict"`.
* `waf` - (Optional) Whether this action is `"on"` or `"off"`.

Forwarding URL actions support the following:

Expand All @@ -72,4 +76,4 @@ The following attributes are exported:
* `target` - The URL pattern targeted by the page rule.
* `actions` - The actions applied by the page rule.
* `priority` - The priority of the page rule.
* `status` - Whether the page rule is active or paused.
* `status` - Whether the page rule is active or disabled.