» cloudflare_page_rule

Provides a Cloudflare page rule resource.

» Example Usage

# Add a page rule to the domain
resource "cloudflare_page_rule" "foobar" {
  zone = "${var.cloudflare_zone}"
  target = "sub.${var.cloudflare_zone}/page"
  priority = 1

  actions = {
    ssl = "flexible"
    email_obfuscation = "on"
  }
}

» Argument Reference

The following arguments are supported:

  • zone - (Required) The DNS zone to which the page rule should be added.
  • 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, the higher the number the higher the priority as per API documentation.
  • status - (Optional) Whether the page rule is active or disabled.

Action blocks support the following:

Forwarding URL actions support the following:

  • url - (Required) The URL to which the page rule should forward.
  • status_code - (Required) The status code to use for the redirection.

» Attributes Reference

The following attributes are exported:

  • id - The page rule ID.
  • zone_id - The ID of the zone in which the page rule will be applied.
  • 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 disabled.

» Import

Page rules can be imported using a composite ID formed of zone name and page rule ID, e.g.

$ terraform import cloudflare_page_rule.default example.com/ch8374ftwdghsif43