cloudflare_firewall_rule (Resource)

Define Firewall rules using filter expressions for more control over how traffic is matched to the rule. A filter expression permits selecting traffic by multiple criteria allowing greater freedom in rule creation.

Filter expressions needs to be created first before using Firewall Rule.

Example Usage

resource "cloudflare_filter" "wordpress" {
  zone_id     = "0da42c8d2132a9ddaf714f9e7c920711"
  description = "Wordpress break-in attempts that are outside of the office"
  expression  = "(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.src ne 192.0.2.1"
}

resource "cloudflare_firewall_rule" "wordpress" {
  zone_id     = "0da42c8d2132a9ddaf714f9e7c920711"
  description = "Block wordpress break-in attempts"
  filter_id   = cloudflare_filter.wordpress.id
  action      = "block"
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

$ terraform import cloudflare_firewall_rule.example <zone_id>/<firewall_rule_id>