published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
Provides a Cloudflare WAF rule resource for a particular zone. This can be used to configure firewall behaviour for pre-defined firewall rules.
Example Usage
using System.Collections.Generic;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
return await Deployment.RunAsync(() =>
{
var rule100000 = new Cloudflare.WafRule("rule100000", new()
{
Mode = "simulate",
RuleId = "100000",
ZoneId = "ae36f999674d196762efcc5abb06b345",
});
});
package main
import (
"github.com/pulumi/pulumi-cloudflare/sdk/v4/go/cloudflare"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudflare.NewWafRule(ctx, "rule100000", &cloudflare.WafRuleArgs{
Mode: pulumi.String("simulate"),
RuleId: pulumi.String("100000"),
ZoneId: pulumi.String("ae36f999674d196762efcc5abb06b345"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudflare.WafRule;
import com.pulumi.cloudflare.WafRuleArgs;
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 rule100000 = new WafRule("rule100000", WafRuleArgs.builder()
.mode("simulate")
.ruleId("100000")
.zoneId("ae36f999674d196762efcc5abb06b345")
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
const rule100000 = new cloudflare.WafRule("rule100000", {
mode: "simulate",
ruleId: "100000",
zoneId: "ae36f999674d196762efcc5abb06b345",
});
import pulumi
import pulumi_cloudflare as cloudflare
rule100000 = cloudflare.WafRule("rule100000",
mode="simulate",
rule_id="100000",
zone_id="ae36f999674d196762efcc5abb06b345")
resources:
rule100000:
type: cloudflare:WafRule
properties:
mode: simulate
ruleId: '100000'
zoneId: ae36f999674d196762efcc5abb06b345
Create WafRule Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new WafRule(name: string, args: WafRuleArgs, opts?: CustomResourceOptions);@overload
def WafRule(resource_name: str,
args: WafRuleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def WafRule(resource_name: str,
opts: Optional[ResourceOptions] = None,
mode: Optional[str] = None,
rule_id: Optional[str] = None,
zone_id: Optional[str] = None,
package_id: Optional[str] = None)func NewWafRule(ctx *Context, name string, args WafRuleArgs, opts ...ResourceOption) (*WafRule, error)public WafRule(string name, WafRuleArgs args, CustomResourceOptions? opts = null)
public WafRule(String name, WafRuleArgs args)
public WafRule(String name, WafRuleArgs args, CustomResourceOptions options)
type: cloudflare:WafRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args WafRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args WafRuleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args WafRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args WafRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args WafRuleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var wafRuleResource = new Cloudflare.WafRule("wafRuleResource", new()
{
Mode = "string",
RuleId = "string",
ZoneId = "string",
PackageId = "string",
});
example, err := cloudflare.NewWafRule(ctx, "wafRuleResource", &cloudflare.WafRuleArgs{
Mode: pulumi.String("string"),
RuleId: pulumi.String("string"),
ZoneId: pulumi.String("string"),
PackageId: pulumi.String("string"),
})
var wafRuleResource = new WafRule("wafRuleResource", WafRuleArgs.builder()
.mode("string")
.ruleId("string")
.zoneId("string")
.packageId("string")
.build());
waf_rule_resource = cloudflare.WafRule("wafRuleResource",
mode="string",
rule_id="string",
zone_id="string",
package_id="string")
const wafRuleResource = new cloudflare.WafRule("wafRuleResource", {
mode: "string",
ruleId: "string",
zoneId: "string",
packageId: "string",
});
type: cloudflare:WafRule
properties:
mode: string
packageId: string
ruleId: string
zoneId: string
WafRule Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The WafRule resource accepts the following input properties:
- mode str
- The mode of the rule, can be one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
- rule_
id str - The WAF Rule ID.
- zone_
id str - The DNS zone ID to apply to.
- package_
id str - The ID of the WAF Rule Package that contains the rule.
Outputs
All input properties are implicitly available as output properties. Additionally, the WafRule resource produces the following output properties:
Look up Existing WafRule Resource
Get an existing WafRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: WafRuleState, opts?: CustomResourceOptions): WafRule@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
group_id: Optional[str] = None,
mode: Optional[str] = None,
package_id: Optional[str] = None,
rule_id: Optional[str] = None,
zone_id: Optional[str] = None) -> WafRulefunc GetWafRule(ctx *Context, name string, id IDInput, state *WafRuleState, opts ...ResourceOption) (*WafRule, error)public static WafRule Get(string name, Input<string> id, WafRuleState? state, CustomResourceOptions? opts = null)public static WafRule get(String name, Output<String> id, WafRuleState state, CustomResourceOptions options)resources: _: type: cloudflare:WafRule get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Group
Id string - The ID of the WAF Rule Group that contains the rule.
- Mode string
- The mode of the rule, can be one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
- Package
Id string - The ID of the WAF Rule Package that contains the rule.
- Rule
Id string - The WAF Rule ID.
- Zone
Id string - The DNS zone ID to apply to.
- Group
Id string - The ID of the WAF Rule Group that contains the rule.
- Mode string
- The mode of the rule, can be one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
- Package
Id string - The ID of the WAF Rule Package that contains the rule.
- Rule
Id string - The WAF Rule ID.
- Zone
Id string - The DNS zone ID to apply to.
- group
Id String - The ID of the WAF Rule Group that contains the rule.
- mode String
- The mode of the rule, can be one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
- package
Id String - The ID of the WAF Rule Package that contains the rule.
- rule
Id String - The WAF Rule ID.
- zone
Id String - The DNS zone ID to apply to.
- group
Id string - The ID of the WAF Rule Group that contains the rule.
- mode string
- The mode of the rule, can be one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
- package
Id string - The ID of the WAF Rule Package that contains the rule.
- rule
Id string - The WAF Rule ID.
- zone
Id string - The DNS zone ID to apply to.
- group_
id str - The ID of the WAF Rule Group that contains the rule.
- mode str
- The mode of the rule, can be one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
- package_
id str - The ID of the WAF Rule Package that contains the rule.
- rule_
id str - The WAF Rule ID.
- zone_
id str - The DNS zone ID to apply to.
- group
Id String - The ID of the WAF Rule Group that contains the rule.
- mode String
- The mode of the rule, can be one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
- package
Id String - The ID of the WAF Rule Package that contains the rule.
- rule
Id String - The WAF Rule ID.
- zone
Id String - The DNS zone ID to apply to.
Import
Rules can be imported using a composite ID formed of zone ID and the WAF Rule ID, e.g.
$ pulumi import cloudflare:index/wafRule:WafRule 100000 ae36f999674d196762efcc5abb06b345/100000
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Cloudflare pulumi/pulumi-cloudflare
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
cloudflareTerraform Provider.
published on Monday, Mar 9, 2026 by Pulumi
