Package com.pulumi.aws.wafv2
Class RuleGroup
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.wafv2.RuleGroup
-
public class RuleGroup extends com.pulumi.resources.CustomResourceCreates a WAFv2 Rule Group resource. ## Example Usage ### Simple
### Complexpackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.wafv2.RuleGroup; import com.pulumi.aws.wafv2.RuleGroupArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupVisibilityConfigArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleActionArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleActionAllowArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementGeoMatchStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleVisibilityConfigArgs; import java.util.ArrayList; import java.util.Arrays; 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 example = new RuleGroup("example", RuleGroupArgs.builder() .visibilityConfig(RuleGroupVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("friendly-metric-name") .sampledRequestsEnabled(false) .build()) .rules(RuleGroupRuleArgs.builder() .action(RuleGroupRuleActionArgs.builder() .allow(RuleGroupRuleActionAllowArgs.builder() .build()) .build()) .statement(RuleGroupRuleStatementArgs.builder() .geoMatchStatement(RuleGroupRuleStatementGeoMatchStatementArgs.builder() .countryCodes( "US", "NL") .build()) .build()) .visibilityConfig(RuleGroupRuleVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("friendly-rule-metric-name") .sampledRequestsEnabled(false) .build()) .name("rule-1") .priority(1) .build()) .name("example-rule") .scope("REGIONAL") .capacity(2) .build()); } }
### Using rulesJsonpackage generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.wafv2.IpSet; import com.pulumi.aws.wafv2.IpSetArgs; import com.pulumi.aws.wafv2.RegexPatternSet; import com.pulumi.aws.wafv2.RegexPatternSetArgs; import com.pulumi.aws.wafv2.inputs.RegexPatternSetRegularExpressionArgs; import com.pulumi.aws.wafv2.RuleGroup; import com.pulumi.aws.wafv2.RuleGroupArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupVisibilityConfigArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleActionArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleActionBlockArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementNotStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementAndStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementGeoMatchStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementByteMatchStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementByteMatchStatementFieldToMatchArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementByteMatchStatementFieldToMatchAllQueryArgumentsArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementByteMatchStatementTextTransformationArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleVisibilityConfigArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleActionCountArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementOrStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexMatchStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexMatchStatementFieldToMatchArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexMatchStatementFieldToMatchSingleHeaderArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexMatchStatementTextTransformationArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSqliMatchStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSqliMatchStatementFieldToMatchArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSqliMatchStatementFieldToMatchBodyArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSqliMatchStatementTextTransformationArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementXssMatchStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementXssMatchStatementFieldToMatchArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementXssMatchStatementFieldToMatchMethodArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementXssMatchStatementTextTransformationArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleCaptchaConfigArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleCaptchaConfigImmunityTimePropertyArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSizeConstraintStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSizeConstraintStatementFieldToMatchArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSizeConstraintStatementFieldToMatchSingleQueryArgumentArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementSizeConstraintStatementTextTransformationArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementIpSetReferenceStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexPatternSetReferenceStatementArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexPatternSetReferenceStatementFieldToMatchArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexPatternSetReferenceStatementFieldToMatchSingleHeaderArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupRuleStatementRegexPatternSetReferenceStatementTextTransformationArgs; import java.util.ArrayList; import java.util.Arrays; 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 test = new IpSet("test", IpSetArgs.builder() .name("test") .scope("REGIONAL") .ipAddressVersion("IPV4") .addresses( "1.1.1.1/32", "2.2.2.2/32") .build()); var testRegexPatternSet = new RegexPatternSet("testRegexPatternSet", RegexPatternSetArgs.builder() .regularExpressions(RegexPatternSetRegularExpressionArgs.builder() .regexString("one") .build()) .name("test") .scope("REGIONAL") .build()); var example = new RuleGroup("example", RuleGroupArgs.builder() .visibilityConfig(RuleGroupVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("friendly-metric-name") .sampledRequestsEnabled(false) .build()) .captchaConfig(Arrays.asList(Map.of("immunityTimeProperty", Arrays.asList(Map.of("immunityTime", 120))))) .rules( RuleGroupRuleArgs.builder() .action(RuleGroupRuleActionArgs.builder() .block(RuleGroupRuleActionBlockArgs.builder() .build()) .build()) .statement(Map.of("notStatement", RuleGroupRuleStatementNotStatementArgs.builder() .statements(Map.of("andStatement", Map.of("statements", Arrays.asList( RuleGroupRuleStatementArgs.builder() .geoMatchStatement(RuleGroupRuleStatementGeoMatchStatementArgs.builder() .countryCodes("US") .build()) .build(), RuleGroupRuleStatementArgs.builder() .byteMatchStatement(RuleGroupRuleStatementByteMatchStatementArgs.builder() .fieldToMatch(RuleGroupRuleStatementByteMatchStatementFieldToMatchArgs.builder() .allQueryArguments(RuleGroupRuleStatementByteMatchStatementFieldToMatchAllQueryArgumentsArgs.builder() .build()) .build()) .textTransformations( RuleGroupRuleStatementByteMatchStatementTextTransformationArgs.builder() .priority(5) .type("CMD_LINE") .build(), RuleGroupRuleStatementByteMatchStatementTextTransformationArgs.builder() .priority(2) .type("LOWERCASE") .build()) .positionalConstraint("CONTAINS") .searchString("word") .build()) .build())))) .build())) .visibilityConfig(RuleGroupRuleVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("rule-1") .sampledRequestsEnabled(false) .build()) .name("rule-1") .priority(1) .build(), RuleGroupRuleArgs.builder() .action(RuleGroupRuleActionArgs.builder() .count(RuleGroupRuleActionCountArgs.builder() .build()) .build()) .statement(Map.of("orStatement", Map.of("statements", Arrays.asList( RuleGroupRuleStatementArgs.builder() .regexMatchStatement(RuleGroupRuleStatementRegexMatchStatementArgs.builder() .fieldToMatch(RuleGroupRuleStatementRegexMatchStatementFieldToMatchArgs.builder() .singleHeader(RuleGroupRuleStatementRegexMatchStatementFieldToMatchSingleHeaderArgs.builder() .name("user-agent") .build()) .build()) .textTransformations(RuleGroupRuleStatementRegexMatchStatementTextTransformationArgs.builder() .priority(6) .type("NONE") .build()) .regexString("a-z?") .build()) .build(), RuleGroupRuleStatementArgs.builder() .sqliMatchStatement(RuleGroupRuleStatementSqliMatchStatementArgs.builder() .fieldToMatch(RuleGroupRuleStatementSqliMatchStatementFieldToMatchArgs.builder() .body(RuleGroupRuleStatementSqliMatchStatementFieldToMatchBodyArgs.builder() .build()) .build()) .textTransformations( RuleGroupRuleStatementSqliMatchStatementTextTransformationArgs.builder() .priority(5) .type("URL_DECODE") .build(), RuleGroupRuleStatementSqliMatchStatementTextTransformationArgs.builder() .priority(4) .type("HTML_ENTITY_DECODE") .build(), RuleGroupRuleStatementSqliMatchStatementTextTransformationArgs.builder() .priority(3) .type("COMPRESS_WHITE_SPACE") .build()) .build()) .build(), RuleGroupRuleStatementArgs.builder() .xssMatchStatement(RuleGroupRuleStatementXssMatchStatementArgs.builder() .fieldToMatch(RuleGroupRuleStatementXssMatchStatementFieldToMatchArgs.builder() .method(RuleGroupRuleStatementXssMatchStatementFieldToMatchMethodArgs.builder() .build()) .build()) .textTransformations(RuleGroupRuleStatementXssMatchStatementTextTransformationArgs.builder() .priority(2) .type("NONE") .build()) .build()) .build())))) .visibilityConfig(RuleGroupRuleVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("rule-2") .sampledRequestsEnabled(false) .build()) .captchaConfig(RuleGroupRuleCaptchaConfigArgs.builder() .immunityTimeProperty(RuleGroupRuleCaptchaConfigImmunityTimePropertyArgs.builder() .immunityTime(240) .build()) .build()) .name("rule-2") .priority(2) .build(), RuleGroupRuleArgs.builder() .action(RuleGroupRuleActionArgs.builder() .block(RuleGroupRuleActionBlockArgs.builder() .build()) .build()) .statement(RuleGroupRuleStatementArgs.builder() .sizeConstraintStatement(RuleGroupRuleStatementSizeConstraintStatementArgs.builder() .fieldToMatch(RuleGroupRuleStatementSizeConstraintStatementFieldToMatchArgs.builder() .singleQueryArgument(RuleGroupRuleStatementSizeConstraintStatementFieldToMatchSingleQueryArgumentArgs.builder() .name("username") .build()) .build()) .textTransformations(RuleGroupRuleStatementSizeConstraintStatementTextTransformationArgs.builder() .priority(5) .type("NONE") .build()) .comparisonOperator("GT") .size(100) .build()) .build()) .visibilityConfig(RuleGroupRuleVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("rule-3") .sampledRequestsEnabled(false) .build()) .name("rule-3") .priority(3) .build(), RuleGroupRuleArgs.builder() .action(RuleGroupRuleActionArgs.builder() .block(RuleGroupRuleActionBlockArgs.builder() .build()) .build()) .statement(Map.of("orStatement", RuleGroupRuleStatementOrStatementArgs.builder() .statements( RuleGroupRuleStatementArgs.builder() .ipSetReferenceStatement(RuleGroupRuleStatementIpSetReferenceStatementArgs.builder() .arn(test.arn()) .build()) .build(), RuleGroupRuleStatementArgs.builder() .regexPatternSetReferenceStatement(RuleGroupRuleStatementRegexPatternSetReferenceStatementArgs.builder() .fieldToMatch(RuleGroupRuleStatementRegexPatternSetReferenceStatementFieldToMatchArgs.builder() .singleHeader(RuleGroupRuleStatementRegexPatternSetReferenceStatementFieldToMatchSingleHeaderArgs.builder() .name("referer") .build()) .build()) .textTransformations(RuleGroupRuleStatementRegexPatternSetReferenceStatementTextTransformationArgs.builder() .priority(2) .type("NONE") .build()) .arn(testRegexPatternSet.arn()) .build()) .build()) .build())) .visibilityConfig(RuleGroupRuleVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("rule-4") .sampledRequestsEnabled(false) .build()) .name("rule-4") .priority(4) .build()) .name("complex-example") .description("An rule group containing all statements") .scope("REGIONAL") .capacity(500) .tags(Map.ofEntries( Map.entry("Name", "example-and-statement"), Map.entry("Code", "123456") )) .build()); } }
## Import Using `pulumi import`, import WAFv2 Rule Group using `ID/name/scope`. For example: ```sh $ pulumi import aws:wafv2/ruleGroup:RuleGroup example a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc/example/REGIONAL ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.wafv2.RuleGroup; import com.pulumi.aws.wafv2.RuleGroupArgs; import com.pulumi.aws.wafv2.inputs.RuleGroupVisibilityConfigArgs; import static com.pulumi.codegen.internal.Serialization.*; import java.util.ArrayList; import java.util.Arrays; 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 example = new RuleGroup("example", RuleGroupArgs.builder() .visibilityConfig(RuleGroupVisibilityConfigArgs.builder() .cloudwatchMetricsEnabled(false) .metricName("friendly-metric-name") .sampledRequestsEnabled(false) .build()) .name("example-rule-group") .scope("REGIONAL") .capacity(100) .rulesJson(serializeJson( jsonArray(jsonObject( jsonProperty("Name", "rule-1"), jsonProperty("Priority", 1), jsonProperty("Action", jsonObject( jsonProperty("Count", jsonObject( )) )), jsonProperty("Statement", jsonObject( jsonProperty("ByteMatchStatement", jsonObject( jsonProperty("SearchString", "badbot"), jsonProperty("FieldToMatch", jsonObject( jsonProperty("UriPath", jsonObject( )) )), jsonProperty("TextTransformations", jsonArray(jsonObject( jsonProperty("Priority", 1), jsonProperty("Type", "NONE") ))), jsonProperty("PositionalConstraint", "CONTAINS") )) )), jsonProperty("VisibilityConfig", jsonObject( jsonProperty("CloudwatchMetricsEnabled", false), jsonProperty("MetricName", "friendly-rule-metric-name"), jsonProperty("SampledRequestsEnabled", false) )) )))) .build()); } }
-
-
Constructor Summary
Constructors Constructor Description RuleGroup(java.lang.String name)RuleGroup(java.lang.String name, RuleGroupArgs args)RuleGroup(java.lang.String name, RuleGroupArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>arn()com.pulumi.core.Output<java.lang.Integer>capacity()com.pulumi.core.Output<java.util.Optional<java.util.List<RuleGroupCustomResponseBody>>>customResponseBodies()com.pulumi.core.Output<java.util.Optional<java.lang.String>>description()static RuleGroupget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, RuleGroupState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>lockToken()com.pulumi.core.Output<java.util.Optional<RuleGroupMonetizationConfig>>monetizationConfig()com.pulumi.core.Output<java.lang.String>name()com.pulumi.core.Output<java.lang.String>namePrefix()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.util.Optional<java.util.List<RuleGroupRule>>>rules()com.pulumi.core.Output<java.util.Optional<java.lang.String>>rulesJson()com.pulumi.core.Output<java.lang.String>scope()com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>tags()com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>tagsAll()com.pulumi.core.Output<RuleGroupVisibilityConfig>visibilityConfig()
-
-
-
Constructor Detail
-
RuleGroup
public RuleGroup(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
RuleGroup
public RuleGroup(java.lang.String name, RuleGroupArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
RuleGroup
public RuleGroup(java.lang.String name, RuleGroupArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- ARN of the WAF rule group.
-
capacity
public com.pulumi.core.Output<java.lang.Integer> capacity()
- Returns:
- Web ACL capacity units (WCUs) required for this rule group. See [here](https://docs.aws.amazon.com/waf/latest/APIReference/API_CreateRuleGroup.html#API_CreateRuleGroup_RequestSyntax) for general information and [here](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statements-list.html) for capacity specific information.
-
customResponseBodies
public com.pulumi.core.Output<java.util.Optional<java.util.List<RuleGroupCustomResponseBody>>> customResponseBodies()
- Returns:
- Custom response bodies that can be referenced by `customResponse` actions. See Custom Response Body below for details.
-
description
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
- Returns:
- Friendly description of the rule group.
-
lockToken
public com.pulumi.core.Output<java.lang.String> lockToken()
-
monetizationConfig
public com.pulumi.core.Output<java.util.Optional<RuleGroupMonetizationConfig>> monetizationConfig()
- Returns:
- Monetization configuration for the rule group. Required when any rule uses the `monetize` action. See `monetizationConfig` below for details.
-
name
public com.pulumi.core.Output<java.lang.String> name()
- Returns:
- Friendly name of the rule group.
-
namePrefix
public com.pulumi.core.Output<java.lang.String> namePrefix()
- Returns:
- Creates a unique name beginning with the specified prefix. Conflicts with `name`.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
rules
public com.pulumi.core.Output<java.util.Optional<java.util.List<RuleGroupRule>>> rules()
- Returns:
- Rule blocks used to identify the web requests that you want to `allow`, `block`, or `count`. See Rules below for details.
-
rulesJson
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> rulesJson()
- Returns:
- Raw JSON string to allow more than three nested statements. Conflicts with `rule` attribute. This is for advanced use cases where more than 3 levels of nested statements are required. **There is no drift detection at this time**. If you use this attribute instead of `rule`, you will be foregoing drift detection. Additionally, importing an existing rule group into a configuration with `rulesJson` set will result in a one time in-place update as the remote rule configuration is initially written to the `rule` attribute. See the AWS [documentation](https://docs.aws.amazon.com/waf/latest/APIReference/API_CreateRuleGroup.html) for the JSON structure.
-
scope
public com.pulumi.core.Output<java.lang.String> scope()
- Returns:
- Scope of the rule group, either an AWS CloudFront distribution or a regional application. Valid values are `CLOUDFRONT` or `REGIONAL`. To work with CloudFront, you must also specify the region `us-east-1` (N. Virginia) on the AWS provider.
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- Array of key:value pairs to associate with the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
-
visibilityConfig
public com.pulumi.core.Output<RuleGroupVisibilityConfig> visibilityConfig()
- Returns:
- Amazon CloudWatch metrics and web request sample collection configuration. See Visibility Configuration below for details.
-
get
public static RuleGroup get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable RuleGroupState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-