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_Rule change to and from a forwarding_url fails due to faulty validation error. #265

Closed
andrevdh opened this issue Mar 20, 2019 · 2 comments · Fixed by #338
Closed

Comments

@andrevdh
Copy link

andrevdh commented Mar 20, 2019

Terraform Version

v0.11.11

Affected Resource(s)

cloudflare_page_rule

Terraform Configuration Files

Changing a page_rule from this:

resource "cloudflare_page_rule" "subdomain_settings" {
  zone     = "${var.domain}"
  target   = "https://subdomain.website.com/*"
  actions = {
      ssl         = "flexible"
      cache_level = "aggressive"
  }
  priority = 43
  status   = "active"
}

to this:

resource "cloudflare_page_rule" "subdomain_settings" {
  zone     = "${var.domain}"
  target   = "https://subdomain.website.com/*"
  actions = {
      forwarding_url {
          url         = "https://offline.website.com/maintenance.html"
          status_code = 302
      }
  }
  priority = 43
  status   = "active"
}

Debug Output


* cloudflare_page_rule.subdomain_settings: 1 error(s) occurred:

* cloudflare_page_rule.subdomain_settings: Failed to update Cloudflare Page Rule: error from makeRequest: HTTP status 400: content "{\"success\":false,\"errors\":[{\"code\":1004,\"message\":\"Page Rule validation failed: See messages for details.\"}],\"messages\":[{\"code\":1,\"message\":\".settings: \\\"forwarding_url\\\" may not be used with \\\"any setting\\\"\",\"type\":null}],\"result\":null}"

Expected Behavior

The ssl and cache_level settings should be removed from the pagerule and the forwarding_url setting added to the page_rule

Actual Behavior

The change is aborted due to a validation error

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan
  2. terraform apply
@andrevdh
Copy link
Author

andrevdh commented Mar 20, 2019

The same validation issue also happens when you try to reverse the change. We needed to update the rule manually in the CloudFlare web UI (which applies the exact same change without any problem)

@jacobbednarz
Copy link
Member

Thanks for the report! The crux of the issue here is that we're using the PATCH endpoint to update in place instead of the PUT endpoint which replaces the rule entirely (what you see working in the UI). The reasoning for this (and some options) are called out in #198.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants