1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. getWafRules
Viewing docs for Cloudflare v4.16.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
cloudflare logo
Viewing docs for Cloudflare v4.16.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Use this data source to look up WAF Rules.

    Example Usage

    The example below matches all WAF Rules that are in the group of ID

    using System.Collections.Generic;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var test = Cloudflare.GetWafRules.Invoke(new()
        {
            ZoneId = "ae36f999674d196762efcc5abb06b345",
            PackageId = "a25a9a7e9c00afc1fb2e0245519d725b",
            Filter = new Cloudflare.Inputs.GetWafRulesFilterInputArgs
            {
                Description = ".*example.*",
                Mode = "on",
                GroupId = "de677e5818985db1285d0e80225f06e5",
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["wafRules"] = test.Apply(getWafRulesResult => getWafRulesResult.Rules),
        };
    });
    
    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 {
    		test, err := cloudflare.GetWafRules(ctx, &cloudflare.GetWafRulesArgs{
    			ZoneId:    "ae36f999674d196762efcc5abb06b345",
    			PackageId: pulumi.StringRef("a25a9a7e9c00afc1fb2e0245519d725b"),
    			Filter: cloudflare.GetWafRulesFilter{
    				Description: pulumi.StringRef(".*example.*"),
    				Mode:        pulumi.StringRef("on"),
    				GroupId:     pulumi.StringRef("de677e5818985db1285d0e80225f06e5"),
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("wafRules", test.Rules)
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.CloudflareFunctions;
    import com.pulumi.cloudflare.inputs.GetWafRulesArgs;
    import com.pulumi.cloudflare.inputs.GetWafRulesFilterArgs;
    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) {
            final var test = CloudflareFunctions.getWafRules(GetWafRulesArgs.builder()
                .zoneId("ae36f999674d196762efcc5abb06b345")
                .packageId("a25a9a7e9c00afc1fb2e0245519d725b")
                .filter(GetWafRulesFilterArgs.builder()
                    .description(".*example.*")
                    .mode("on")
                    .groupId("de677e5818985db1285d0e80225f06e5")
                    .build())
                .build());
    
            ctx.export("wafRules", test.applyValue(getWafRulesResult -> getWafRulesResult.rules()));
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const test = cloudflare.getWafRules({
        zoneId: "ae36f999674d196762efcc5abb06b345",
        packageId: "a25a9a7e9c00afc1fb2e0245519d725b",
        filter: {
            description: ".*example.*",
            mode: "on",
            groupId: "de677e5818985db1285d0e80225f06e5",
        },
    });
    export const wafRules = test.then(test => test.rules);
    
    import pulumi
    import pulumi_cloudflare as cloudflare
    
    test = cloudflare.get_waf_rules(zone_id="ae36f999674d196762efcc5abb06b345",
        package_id="a25a9a7e9c00afc1fb2e0245519d725b",
        filter=cloudflare.GetWafRulesFilterArgs(
            description=".*example.*",
            mode="on",
            group_id="de677e5818985db1285d0e80225f06e5",
        ))
    pulumi.export("wafRules", test.rules)
    
    variables:
      test:
        fn::invoke:
          Function: cloudflare:getWafRules
          Arguments:
            zoneId: ae36f999674d196762efcc5abb06b345
            packageId: a25a9a7e9c00afc1fb2e0245519d725b
            filter:
              description: .*example.*
              mode: on
              groupId: de677e5818985db1285d0e80225f06e5
    outputs:
      wafRules: ${test.rules}
    

    Using getWafRules

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getWafRules(args: GetWafRulesArgs, opts?: InvokeOptions): Promise<GetWafRulesResult>
    function getWafRulesOutput(args: GetWafRulesOutputArgs, opts?: InvokeOptions): Output<GetWafRulesResult>
    def get_waf_rules(filter: Optional[GetWafRulesFilter] = None,
                      package_id: Optional[str] = None,
                      zone_id: Optional[str] = None,
                      opts: Optional[InvokeOptions] = None) -> GetWafRulesResult
    def get_waf_rules_output(filter: Optional[pulumi.Input[GetWafRulesFilterArgs]] = None,
                      package_id: Optional[pulumi.Input[str]] = None,
                      zone_id: Optional[pulumi.Input[str]] = None,
                      opts: Optional[InvokeOptions] = None) -> Output[GetWafRulesResult]
    func GetWafRules(ctx *Context, args *GetWafRulesArgs, opts ...InvokeOption) (*GetWafRulesResult, error)
    func GetWafRulesOutput(ctx *Context, args *GetWafRulesOutputArgs, opts ...InvokeOption) GetWafRulesResultOutput

    > Note: This function is named GetWafRules in the Go SDK.

    public static class GetWafRules 
    {
        public static Task<GetWafRulesResult> InvokeAsync(GetWafRulesArgs args, InvokeOptions? opts = null)
        public static Output<GetWafRulesResult> Invoke(GetWafRulesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetWafRulesResult> getWafRules(GetWafRulesArgs args, InvokeOptions options)
    public static Output<GetWafRulesResult> getWafRules(GetWafRulesArgs args, InvokeOptions options)
    
    fn::invoke:
      function: cloudflare:index/getWafRules:getWafRules
      arguments:
        # arguments dictionary

    The following arguments are supported:

    ZoneId string
    The ID of the DNS zone in which to search for the WAF Rules.
    Filter GetWafRulesFilter
    One or more values used to look up WAF Rules. If more than one value is given all values must match in order to be included, see below for full list.
    PackageId string
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    ZoneId string
    The ID of the DNS zone in which to search for the WAF Rules.
    Filter GetWafRulesFilter
    One or more values used to look up WAF Rules. If more than one value is given all values must match in order to be included, see below for full list.
    PackageId string
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    zoneId String
    The ID of the DNS zone in which to search for the WAF Rules.
    filter GetWafRulesFilter
    One or more values used to look up WAF Rules. If more than one value is given all values must match in order to be included, see below for full list.
    packageId String
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    zoneId string
    The ID of the DNS zone in which to search for the WAF Rules.
    filter GetWafRulesFilter
    One or more values used to look up WAF Rules. If more than one value is given all values must match in order to be included, see below for full list.
    packageId string
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    zone_id str
    The ID of the DNS zone in which to search for the WAF Rules.
    filter GetWafRulesFilter
    One or more values used to look up WAF Rules. If more than one value is given all values must match in order to be included, see below for full list.
    package_id str
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    zoneId String
    The ID of the DNS zone in which to search for the WAF Rules.
    filter Property Map
    One or more values used to look up WAF Rules. If more than one value is given all values must match in order to be included, see below for full list.
    packageId String
    The ID of the WAF Rule Package in which to search for the WAF Rules.

    getWafRules Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Rules List<GetWafRulesRule>
    A map of WAF Rules details. Full list below:
    ZoneId string
    Filter GetWafRulesFilter
    PackageId string
    The ID of the WAF Rule Package that contains the WAF Rule
    Id string
    The provider-assigned unique ID for this managed resource.
    Rules []GetWafRulesRule
    A map of WAF Rules details. Full list below:
    ZoneId string
    Filter GetWafRulesFilter
    PackageId string
    The ID of the WAF Rule Package that contains the WAF Rule
    id String
    The provider-assigned unique ID for this managed resource.
    rules List<GetWafRulesRule>
    A map of WAF Rules details. Full list below:
    zoneId String
    filter GetWafRulesFilter
    packageId String
    The ID of the WAF Rule Package that contains the WAF Rule
    id string
    The provider-assigned unique ID for this managed resource.
    rules GetWafRulesRule[]
    A map of WAF Rules details. Full list below:
    zoneId string
    filter GetWafRulesFilter
    packageId string
    The ID of the WAF Rule Package that contains the WAF Rule
    id str
    The provider-assigned unique ID for this managed resource.
    rules Sequence[GetWafRulesRule]
    A map of WAF Rules details. Full list below:
    zone_id str
    filter GetWafRulesFilter
    package_id str
    The ID of the WAF Rule Package that contains the WAF Rule
    id String
    The provider-assigned unique ID for this managed resource.
    rules List<Property Map>
    A map of WAF Rules details. Full list below:
    zoneId String
    filter Property Map
    packageId String
    The ID of the WAF Rule Package that contains the WAF Rule

    Supporting Types

    GetWafRulesFilter

    Description string
    A regular expression matching the description of the WAF Rules to lookup.
    GroupId string
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    Mode string
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    Description string
    A regular expression matching the description of the WAF Rules to lookup.
    GroupId string
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    Mode string
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    description String
    A regular expression matching the description of the WAF Rules to lookup.
    groupId String
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    mode String
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    description string
    A regular expression matching the description of the WAF Rules to lookup.
    groupId string
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    mode string
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    description str
    A regular expression matching the description of the WAF Rules to lookup.
    group_id str
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    mode str
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    description String
    A regular expression matching the description of the WAF Rules to lookup.
    groupId String
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    mode String
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.

    GetWafRulesRule

    AllowedModes List<string>
    The list of allowed mode values for the WAF Rule
    DefaultMode string
    The default mode value for the WAF Rule
    Description string
    A regular expression matching the description of the WAF Rules to lookup.
    GroupId string
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    GroupName string
    The Name of the WAF Rule Group that contains the WAF Rule
    Id string
    The WAF Rule ID
    Mode string
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    PackageId string
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    Priority string
    The WAF Rule priority
    AllowedModes []string
    The list of allowed mode values for the WAF Rule
    DefaultMode string
    The default mode value for the WAF Rule
    Description string
    A regular expression matching the description of the WAF Rules to lookup.
    GroupId string
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    GroupName string
    The Name of the WAF Rule Group that contains the WAF Rule
    Id string
    The WAF Rule ID
    Mode string
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    PackageId string
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    Priority string
    The WAF Rule priority
    allowedModes List<String>
    The list of allowed mode values for the WAF Rule
    defaultMode String
    The default mode value for the WAF Rule
    description String
    A regular expression matching the description of the WAF Rules to lookup.
    groupId String
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    groupName String
    The Name of the WAF Rule Group that contains the WAF Rule
    id String
    The WAF Rule ID
    mode String
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    packageId String
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    priority String
    The WAF Rule priority
    allowedModes string[]
    The list of allowed mode values for the WAF Rule
    defaultMode string
    The default mode value for the WAF Rule
    description string
    A regular expression matching the description of the WAF Rules to lookup.
    groupId string
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    groupName string
    The Name of the WAF Rule Group that contains the WAF Rule
    id string
    The WAF Rule ID
    mode string
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    packageId string
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    priority string
    The WAF Rule priority
    allowed_modes Sequence[str]
    The list of allowed mode values for the WAF Rule
    default_mode str
    The default mode value for the WAF Rule
    description str
    A regular expression matching the description of the WAF Rules to lookup.
    group_id str
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    group_name str
    The Name of the WAF Rule Group that contains the WAF Rule
    id str
    The WAF Rule ID
    mode str
    Mode of the WAF Rules to lookup. Valid values: 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 in which to search for the WAF Rules.
    priority str
    The WAF Rule priority
    allowedModes List<String>
    The list of allowed mode values for the WAF Rule
    defaultMode String
    The default mode value for the WAF Rule
    description String
    A regular expression matching the description of the WAF Rules to lookup.
    groupId String
    The ID of the WAF Rule Group in which the WAF Rules to lookup have to be.
    groupName String
    The Name of the WAF Rule Group that contains the WAF Rule
    id String
    The WAF Rule ID
    mode String
    Mode of the WAF Rules to lookup. Valid values: one of ["block", "challenge", "default", "disable", "simulate"] or ["on", "off"] depending on the WAF Rule type.
    packageId String
    The ID of the WAF Rule Package in which to search for the WAF Rules.
    priority String
    The WAF Rule priority

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Viewing docs for Cloudflare v4.16.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.