Firewall Rule Args
data class FirewallRuleArgs(val action: Output<String>? = null, val description: Output<String>? = null, val filterId: Output<String>? = null, val paused: Output<Boolean>? = null, val priority: Output<Int>? = null, val products: Output<List<String>>? = null, val zoneId: Output<String>? = null) : ConvertibleToJava<FirewallRuleArgs>
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.
cloudflare.FirewallRule
is in a deprecation phase until June 15th, 2025. During this time period, this resource is still fully supported but you are strongly advised to move to thecloudflare.Ruleset
resource. Full details can be found in the developer documentation.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
const wordpress = new cloudflare.Filter("wordpress", {
zoneId: "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",
});
const wordpressFirewallRule = new cloudflare.FirewallRule("wordpress", {
zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
description: "Block wordpress break-in attempts",
filterId: wordpress.id,
action: "block",
});
Content copied to clipboard
import pulumi
import pulumi_cloudflare as cloudflare
wordpress = 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")
wordpress_firewall_rule = cloudflare.FirewallRule("wordpress",
zone_id="0da42c8d2132a9ddaf714f9e7c920711",
description="Block wordpress break-in attempts",
filter_id=wordpress.id,
action="block")
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
return await Deployment.RunAsync(() =>
{
var wordpress = new Cloudflare.Filter("wordpress", new()
{
ZoneId = "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",
});
var wordpressFirewallRule = new Cloudflare.FirewallRule("wordpress", new()
{
ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
Description = "Block wordpress break-in attempts",
FilterId = wordpress.Id,
Action = "block",
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
wordpress, err := cloudflare.NewFilter(ctx, "wordpress", &cloudflare.FilterArgs{
ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
Description: pulumi.String("Wordpress break-in attempts that are outside of the office"),
Expression: pulumi.String("(http.request.uri.path ~ \".*wp-login.php\" or http.request.uri.path ~ \".*xmlrpc.php\") and ip.src ne 192.0.2.1"),
})
if err != nil {
return err
}
_, err = cloudflare.NewFirewallRule(ctx, "wordpress", &cloudflare.FirewallRuleArgs{
ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
Description: pulumi.String("Block wordpress break-in attempts"),
FilterId: wordpress.ID(),
Action: pulumi.String("block"),
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudflare.Filter;
import com.pulumi.cloudflare.FilterArgs;
import com.pulumi.cloudflare.FirewallRule;
import com.pulumi.cloudflare.FirewallRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var wordpress = new Filter("wordpress", FilterArgs.builder()
.zoneId("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")
.build());
var wordpressFirewallRule = new FirewallRule("wordpressFirewallRule", FirewallRuleArgs.builder()
.zoneId("0da42c8d2132a9ddaf714f9e7c920711")
.description("Block wordpress break-in attempts")
.filterId(wordpress.id())
.action("block")
.build());
}
}
Content copied to clipboard
resources:
wordpress:
type: cloudflare:Filter
properties:
zoneId: 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
wordpressFirewallRule:
type: cloudflare:FirewallRule
name: wordpress
properties:
zoneId: 0da42c8d2132a9ddaf714f9e7c920711
description: Block wordpress break-in attempts
filterId: ${wordpress.id}
action: block
Content copied to clipboard
Import
$ pulumi import cloudflare:index/firewallRule:FirewallRule example <zone_id>/<firewall_rule_id>
Content copied to clipboard