1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. esa
  5. getWafRulesets
Viewing docs for Alibaba Cloud v3.99.0
published on Friday, Apr 10, 2026 by Pulumi
alicloud logo
Viewing docs for Alibaba Cloud v3.99.0
published on Friday, Apr 10, 2026 by Pulumi

    This data source provides the ESA Waf Rulesets of the current Alibaba Cloud user.

    NOTE: Available since v1.274.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.esa.getSites({
        planSubscribeType: "enterpriseplan",
    });
    const defaultWafRuleset = new alicloud.esa.WafRuleset("default", {
        siteId: _default.then(_default => _default.sites?.[0]?.siteId),
        phase: "http_custom",
        siteVersion: 0,
        name: name,
    });
    const ids = pulumi.all([defaultWafRuleset.id, defaultWafRuleset.siteId, defaultWafRuleset.phase, defaultWafRuleset.siteVersion]).apply(([id, siteId, phase, siteVersion]) => alicloud.esa.getWafRulesetsOutput({
        ids: [id],
        siteId: siteId,
        phase: phase,
        siteVersion: siteVersion,
    }));
    export const esaWafRulesetsId0 = ids.apply(ids => ids.sets?.[0]?.id);
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.esa.get_sites(plan_subscribe_type="enterpriseplan")
    default_waf_ruleset = alicloud.esa.WafRuleset("default",
        site_id=default.sites[0].site_id,
        phase="http_custom",
        site_version=0,
        name=name)
    ids = pulumi.Output.all(
        id=default_waf_ruleset.id,
        site_id=default_waf_ruleset.site_id,
        phase=default_waf_ruleset.phase,
        site_version=default_waf_ruleset.site_version
    ).apply(lambda resolved_outputs: alicloud.esa.get_waf_rulesets_output(ids=[resolved_outputs['id']],
        site_id=resolved_outputs['site_id'],
        phase=resolved_outputs['phase'],
        site_version=resolved_outputs['site_version']))
    
    pulumi.export("esaWafRulesetsId0", ids.sets[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/esa"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		name := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_default, err := esa.GetSites(ctx, &esa.GetSitesArgs{
    			PlanSubscribeType: pulumi.StringRef("enterpriseplan"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultWafRuleset, err := esa.NewWafRuleset(ctx, "default", &esa.WafRulesetArgs{
    			SiteId:      pulumi.String(pulumi.Int(_default.Sites[0].SiteId)),
    			Phase:       pulumi.String("http_custom"),
    			SiteVersion: pulumi.Int(0),
    			Name:        pulumi.String(pulumi.String(name)),
    		})
    		if err != nil {
    			return err
    		}
    		ids := pulumi.All(defaultWafRuleset.ID(), defaultWafRuleset.SiteId, defaultWafRuleset.Phase, defaultWafRuleset.SiteVersion).ApplyT(func(_args []interface{}) (esa.GetWafRulesetsResult, error) {
    			id := _args[0].(string)
    			siteId := _args[1].(string)
    			phase := _args[2].(string)
    			siteVersion := _args[3].(*int)
    			return esa.GetWafRulesetsResult(interface{}(esa.GetWafRulesets(ctx, &esa.GetWafRulesetsArgs{
    				Ids: []string{
    					id,
    				},
    				SiteId:      siteId,
    				Phase:       phase,
    				SiteVersion: siteVersion,
    			}, nil))), nil
    		}).(esa.GetWafRulesetsResultOutput)
    		ctx.Export("esaWafRulesetsId0", ids.ApplyT(func(ids esa.GetWafRulesetsResult) (*string, error) {
    			return &ids.Sets[0].Id, nil
    		}).(pulumi.StringPtrOutput))
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.Esa.GetSites.Invoke(new()
        {
            PlanSubscribeType = "enterpriseplan",
        });
    
        var defaultWafRuleset = new AliCloud.Esa.WafRuleset("default", new()
        {
            SiteId = @default.Apply(@default => @default.Apply(getSitesResult => getSitesResult.Sites[0]?.SiteId)),
            Phase = "http_custom",
            SiteVersion = 0,
            Name = name,
        });
    
        var ids = AliCloud.Esa.GetWafRulesets.Invoke(new()
        {
            Ids = new[]
            {
                defaultWafRuleset.Id,
            },
            SiteId = defaultWafRuleset.SiteId,
            Phase = defaultWafRuleset.Phase,
            SiteVersion = defaultWafRuleset.SiteVersion,
        });
    
        return new Dictionary<string, object?>
        {
            ["esaWafRulesetsId0"] = ids.Apply(getWafRulesetsResult => getWafRulesetsResult.Sets[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.esa.EsaFunctions;
    import com.pulumi.alicloud.esa.inputs.GetSitesArgs;
    import com.pulumi.alicloud.esa.WafRuleset;
    import com.pulumi.alicloud.esa.WafRulesetArgs;
    import com.pulumi.alicloud.esa.inputs.GetWafRulesetsArgs;
    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 config = ctx.config();
            final var name = config.get("name").orElse("terraform-example");
            final var default = EsaFunctions.getSites(GetSitesArgs.builder()
                .planSubscribeType("enterpriseplan")
                .build());
    
            var defaultWafRuleset = new WafRuleset("defaultWafRuleset", WafRulesetArgs.builder()
                .siteId(default_.sites()[0].siteId())
                .phase("http_custom")
                .siteVersion(0)
                .name(name)
                .build());
    
            final var ids = Output.tuple(defaultWafRuleset.id(), defaultWafRuleset.siteId(), defaultWafRuleset.phase(), defaultWafRuleset.siteVersion()).applyValue(values -> {
                var id = values.t1;
                var siteId = values.t2;
                var phase = values.t3;
                var siteVersion = values.t4;
                return EsaFunctions.getWafRulesets(GetWafRulesetsArgs.builder()
                    .ids(id)
                    .siteId(siteId)
                    .phase(phase)
                    .siteVersion(siteVersion)
                    .build());
            });
    
            ctx.export("esaWafRulesetsId0", ids.applyValue(_ids -> _ids.sets()[0].id()));
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      defaultWafRuleset:
        type: alicloud:esa:WafRuleset
        name: default
        properties:
          siteId: ${default.sites[0].siteId}
          phase: http_custom
          siteVersion: '0'
          name: ${name}
    variables:
      default:
        fn::invoke:
          function: alicloud:esa:getSites
          arguments:
            planSubscribeType: enterpriseplan
      ids:
        fn::invoke:
          function: alicloud:esa:getWafRulesets
          arguments:
            ids:
              - ${defaultWafRuleset.id}
            siteId: ${defaultWafRuleset.siteId}
            phase: ${defaultWafRuleset.phase}
            siteVersion: ${defaultWafRuleset.siteVersion}
    outputs:
      esaWafRulesetsId0: ${ids.sets[0].id}
    

    Using getWafRulesets

    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 getWafRulesets(args: GetWafRulesetsArgs, opts?: InvokeOptions): Promise<GetWafRulesetsResult>
    function getWafRulesetsOutput(args: GetWafRulesetsOutputArgs, opts?: InvokeOptions): Output<GetWafRulesetsResult>
    def get_waf_rulesets(ids: Optional[Sequence[str]] = None,
                         name_regex: Optional[str] = None,
                         output_file: Optional[str] = None,
                         phase: Optional[str] = None,
                         query_args: Optional[GetWafRulesetsQueryArgs] = None,
                         site_id: Optional[str] = None,
                         site_version: Optional[int] = None,
                         status: Optional[str] = None,
                         opts: Optional[InvokeOptions] = None) -> GetWafRulesetsResult
    def get_waf_rulesets_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                         name_regex: Optional[pulumi.Input[str]] = None,
                         output_file: Optional[pulumi.Input[str]] = None,
                         phase: Optional[pulumi.Input[str]] = None,
                         query_args: Optional[pulumi.Input[GetWafRulesetsQueryArgsArgs]] = None,
                         site_id: Optional[pulumi.Input[str]] = None,
                         site_version: Optional[pulumi.Input[int]] = None,
                         status: Optional[pulumi.Input[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetWafRulesetsResult]
    func GetWafRulesets(ctx *Context, args *GetWafRulesetsArgs, opts ...InvokeOption) (*GetWafRulesetsResult, error)
    func GetWafRulesetsOutput(ctx *Context, args *GetWafRulesetsOutputArgs, opts ...InvokeOption) GetWafRulesetsResultOutput

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

    public static class GetWafRulesets 
    {
        public static Task<GetWafRulesetsResult> InvokeAsync(GetWafRulesetsArgs args, InvokeOptions? opts = null)
        public static Output<GetWafRulesetsResult> Invoke(GetWafRulesetsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetWafRulesetsResult> getWafRulesets(GetWafRulesetsArgs args, InvokeOptions options)
    public static Output<GetWafRulesetsResult> getWafRulesets(GetWafRulesetsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: alicloud:esa/getWafRulesets:getWafRulesets
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Phase string
    The WAF operation phase.
    SiteId string
    The ID of the Site.
    SiteVersion int
    The version of the Site.
    Ids List<string>
    A list of Waf Ruleset IDs.
    NameRegex string
    A regex string to filter results by Waf Ruleset name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    QueryArgs Pulumi.AliCloud.Esa.Inputs.GetWafRulesetsQueryArgs
    The query parameters. See queryArgs below.
    Status string
    The status of the rule set. Valid values: on, off.
    Phase string
    The WAF operation phase.
    SiteId string
    The ID of the Site.
    SiteVersion int
    The version of the Site.
    Ids []string
    A list of Waf Ruleset IDs.
    NameRegex string
    A regex string to filter results by Waf Ruleset name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    QueryArgs GetWafRulesetsQueryArgs
    The query parameters. See queryArgs below.
    Status string
    The status of the rule set. Valid values: on, off.
    phase String
    The WAF operation phase.
    siteId String
    The ID of the Site.
    siteVersion Integer
    The version of the Site.
    ids List<String>
    A list of Waf Ruleset IDs.
    nameRegex String
    A regex string to filter results by Waf Ruleset name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    queryArgs GetWafRulesetsQueryArgs
    The query parameters. See queryArgs below.
    status String
    The status of the rule set. Valid values: on, off.
    phase string
    The WAF operation phase.
    siteId string
    The ID of the Site.
    siteVersion number
    The version of the Site.
    ids string[]
    A list of Waf Ruleset IDs.
    nameRegex string
    A regex string to filter results by Waf Ruleset name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    queryArgs GetWafRulesetsQueryArgs
    The query parameters. See queryArgs below.
    status string
    The status of the rule set. Valid values: on, off.
    phase str
    The WAF operation phase.
    site_id str
    The ID of the Site.
    site_version int
    The version of the Site.
    ids Sequence[str]
    A list of Waf Ruleset IDs.
    name_regex str
    A regex string to filter results by Waf Ruleset name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    query_args GetWafRulesetsQueryArgs
    The query parameters. See queryArgs below.
    status str
    The status of the rule set. Valid values: on, off.
    phase String
    The WAF operation phase.
    siteId String
    The ID of the Site.
    siteVersion Number
    The version of the Site.
    ids List<String>
    A list of Waf Ruleset IDs.
    nameRegex String
    A regex string to filter results by Waf Ruleset name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    queryArgs Property Map
    The query parameters. See queryArgs below.
    status String
    The status of the rule set. Valid values: on, off.

    getWafRulesets Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    Names List<string>
    A list of Waf Ruleset names.
    Phase string
    The WAF operation phase.
    Sets List<Pulumi.AliCloud.Esa.Outputs.GetWafRulesetsSet>
    A list of Waf Rulesets. Each element contains the following attributes:
    SiteId string
    SiteVersion int
    NameRegex string
    OutputFile string
    QueryArgs Pulumi.AliCloud.Esa.Outputs.GetWafRulesetsQueryArgs
    Status string
    The status of the rule set.
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    Names []string
    A list of Waf Ruleset names.
    Phase string
    The WAF operation phase.
    Sets []GetWafRulesetsSet
    A list of Waf Rulesets. Each element contains the following attributes:
    SiteId string
    SiteVersion int
    NameRegex string
    OutputFile string
    QueryArgs GetWafRulesetsQueryArgs
    Status string
    The status of the rule set.
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of Waf Ruleset names.
    phase String
    The WAF operation phase.
    sets List<GetWafRulesetsSet>
    A list of Waf Rulesets. Each element contains the following attributes:
    siteId String
    siteVersion Integer
    nameRegex String
    outputFile String
    queryArgs GetWafRulesetsQueryArgs
    status String
    The status of the rule set.
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    names string[]
    A list of Waf Ruleset names.
    phase string
    The WAF operation phase.
    sets GetWafRulesetsSet[]
    A list of Waf Rulesets. Each element contains the following attributes:
    siteId string
    siteVersion number
    nameRegex string
    outputFile string
    queryArgs GetWafRulesetsQueryArgs
    status string
    The status of the rule set.
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    names Sequence[str]
    A list of Waf Ruleset names.
    phase str
    The WAF operation phase.
    sets Sequence[GetWafRulesetsSet]
    A list of Waf Rulesets. Each element contains the following attributes:
    site_id str
    site_version int
    name_regex str
    output_file str
    query_args GetWafRulesetsQueryArgs
    status str
    The status of the rule set.
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of Waf Ruleset names.
    phase String
    The WAF operation phase.
    sets List<Property Map>
    A list of Waf Rulesets. Each element contains the following attributes:
    siteId String
    siteVersion Number
    nameRegex String
    outputFile String
    queryArgs Property Map
    status String
    The status of the rule set.

    Supporting Types

    GetWafRulesetsQueryArgs

    AnyLike string
    The fuzzy search for rule set ID, rule set name, rule ID, and rule name.
    Desc bool
    Whether to sort in descending order. Valid values: true, false.
    NameLike string
    The fuzzy search for rule set name.
    OrderBy string
    Specify the column to sort by.
    AnyLike string
    The fuzzy search for rule set ID, rule set name, rule ID, and rule name.
    Desc bool
    Whether to sort in descending order. Valid values: true, false.
    NameLike string
    The fuzzy search for rule set name.
    OrderBy string
    Specify the column to sort by.
    anyLike String
    The fuzzy search for rule set ID, rule set name, rule ID, and rule name.
    desc Boolean
    Whether to sort in descending order. Valid values: true, false.
    nameLike String
    The fuzzy search for rule set name.
    orderBy String
    Specify the column to sort by.
    anyLike string
    The fuzzy search for rule set ID, rule set name, rule ID, and rule name.
    desc boolean
    Whether to sort in descending order. Valid values: true, false.
    nameLike string
    The fuzzy search for rule set name.
    orderBy string
    Specify the column to sort by.
    any_like str
    The fuzzy search for rule set ID, rule set name, rule ID, and rule name.
    desc bool
    Whether to sort in descending order. Valid values: true, false.
    name_like str
    The fuzzy search for rule set name.
    order_by str
    Specify the column to sort by.
    anyLike String
    The fuzzy search for rule set ID, rule set name, rule ID, and rule name.
    desc Boolean
    Whether to sort in descending order. Valid values: true, false.
    nameLike String
    The fuzzy search for rule set name.
    orderBy String
    Specify the column to sort by.

    GetWafRulesetsSet

    Fields List<string>
    The list of match objects.
    Id string
    The ID of the WAF Rule Set.
    Name string
    The name of the rule set.
    Phase string
    The WAF operation phase.
    RulesetId string
    The ID of the WAF rule set.
    Status string
    The status of the rule set. Valid values: on, off.
    Target string
    Protection target type in http_bot.
    Types List<string>
    The list of rule types.
    UpdateTime string
    The last modification time of the rule set.
    Fields []string
    The list of match objects.
    Id string
    The ID of the WAF Rule Set.
    Name string
    The name of the rule set.
    Phase string
    The WAF operation phase.
    RulesetId string
    The ID of the WAF rule set.
    Status string
    The status of the rule set. Valid values: on, off.
    Target string
    Protection target type in http_bot.
    Types []string
    The list of rule types.
    UpdateTime string
    The last modification time of the rule set.
    fields List<String>
    The list of match objects.
    id String
    The ID of the WAF Rule Set.
    name String
    The name of the rule set.
    phase String
    The WAF operation phase.
    rulesetId String
    The ID of the WAF rule set.
    status String
    The status of the rule set. Valid values: on, off.
    target String
    Protection target type in http_bot.
    types List<String>
    The list of rule types.
    updateTime String
    The last modification time of the rule set.
    fields string[]
    The list of match objects.
    id string
    The ID of the WAF Rule Set.
    name string
    The name of the rule set.
    phase string
    The WAF operation phase.
    rulesetId string
    The ID of the WAF rule set.
    status string
    The status of the rule set. Valid values: on, off.
    target string
    Protection target type in http_bot.
    types string[]
    The list of rule types.
    updateTime string
    The last modification time of the rule set.
    fields Sequence[str]
    The list of match objects.
    id str
    The ID of the WAF Rule Set.
    name str
    The name of the rule set.
    phase str
    The WAF operation phase.
    ruleset_id str
    The ID of the WAF rule set.
    status str
    The status of the rule set. Valid values: on, off.
    target str
    Protection target type in http_bot.
    types Sequence[str]
    The list of rule types.
    update_time str
    The last modification time of the rule set.
    fields List<String>
    The list of match objects.
    id String
    The ID of the WAF Rule Set.
    name String
    The name of the rule set.
    phase String
    The WAF operation phase.
    rulesetId String
    The ID of the WAF rule set.
    status String
    The status of the rule set. Valid values: on, off.
    target String
    Protection target type in http_bot.
    types List<String>
    The list of rule types.
    updateTime String
    The last modification time of the rule set.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Viewing docs for Alibaba Cloud v3.99.0
    published on Friday, Apr 10, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.