aws-cdk-lib.aws_wafv2.CfnWebACL.RuleProperty

interface RuleProperty

LanguageType name
.NETAmazon.CDK.AWS.WAFv2.CfnWebACL.RuleProperty
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awswafv2#CfnWebACL_RuleProperty
Javasoftware.amazon.awscdk.services.wafv2.CfnWebACL.RuleProperty
Pythonaws_cdk.aws_wafv2.CfnWebACL.RuleProperty
TypeScript aws-cdk-lib » aws_wafv2 » CfnWebACL » RuleProperty

A single rule, which you can use in a WebACL or RuleGroup to identify web requests that you want to allow, block, or count.

Each rule includes one top-level Statement that AWS WAF uses to identify matching web requests, and parameters that govern how AWS WAF handles them.

Example

// The generated example for this type would exceed 500 lines,
// and has been elided for readability.

Properties

NameTypeDescription
namestringThe name of the rule.
prioritynumberIf you define more than one Rule in a WebACL , AWS WAF evaluates each request against the Rules in order based on the value of Priority .
statementIResolvable | StatementPropertyThe AWS WAF processing statement for the rule, for example ByteMatchStatement or SizeConstraintStatement .
visibilityConfigIResolvable | VisibilityConfigPropertyDefines and enables Amazon CloudWatch metrics and web request sample collection.
action?IResolvable | RuleActionPropertyThe action that AWS WAF should take on a web request when it matches the rule's statement.
captchaConfig?IResolvable | CaptchaConfigPropertySpecifies how AWS WAF should handle CAPTCHA evaluations.
challengeConfig?IResolvable | ChallengeConfigPropertySpecifies how AWS WAF should handle Challenge evaluations.
overrideAction?IResolvable | OverrideActionPropertyThe override action to apply to the rules in a rule group, instead of the individual rule action settings.
ruleLabels?IResolvable | IResolvable | LabelProperty[]Labels to apply to web requests that match the rule match statement.

name

Type: string

The name of the rule.

You can't change the name of a Rule after you create it.


priority

Type: number

If you define more than one Rule in a WebACL , AWS WAF evaluates each request against the Rules in order based on the value of Priority .

AWS WAF processes rules with lower priority first. The priorities don't need to be consecutive, but they must all be different.


statement

Type: IResolvable | StatementProperty

The AWS WAF processing statement for the rule, for example ByteMatchStatement or SizeConstraintStatement .


visibilityConfig

Type: IResolvable | VisibilityConfigProperty

Defines and enables Amazon CloudWatch metrics and web request sample collection.


action?

Type: IResolvable | RuleActionProperty (optional)

The action that AWS WAF should take on a web request when it matches the rule's statement.

Settings at the web ACL level can override the rule action setting.

This is used only for rules whose statements don't reference a rule group. Rule statements that reference a rule group are RuleGroupReferenceStatement and ManagedRuleGroupStatement .

You must set either this Action setting or the rule's OverrideAction , but not both:

  • If the rule statement doesn't reference a rule group, you must set this rule action setting and you must not set the rule's override action setting.
  • If the rule statement references a rule group, you must not set this action setting, because the actions are already set on the rules inside the rule group. You must set the rule's override action setting to indicate specifically whether to override the actions that are set on the rules in the rule group.

captchaConfig?

Type: IResolvable | CaptchaConfigProperty (optional)

Specifies how AWS WAF should handle CAPTCHA evaluations.

If you don't specify this, AWS WAF uses the CAPTCHA configuration that's defined for the web ACL.


challengeConfig?

Type: IResolvable | ChallengeConfigProperty (optional)

Specifies how AWS WAF should handle Challenge evaluations.

If you don't specify this, AWS WAF uses the challenge configuration that's defined for the web ACL.


overrideAction?

Type: IResolvable | OverrideActionProperty (optional)

The override action to apply to the rules in a rule group, instead of the individual rule action settings.

This is used only for rules whose statements reference a rule group. Rule statements that reference a rule group are RuleGroupReferenceStatement and ManagedRuleGroupStatement .

Set the override action to none to leave the rule group rule actions in effect. Set it to count to only count matches, regardless of the rule action settings.

You must set either this OverrideAction setting or the Action setting, but not both:

  • If the rule statement references a rule group, you must set this override action setting and you must not set the rule's action setting.
  • If the rule statement doesn't reference a rule group, you must set the rule action setting and you must not set the rule's override action setting.

ruleLabels?

Type: IResolvable | IResolvable | LabelProperty[] (optional)

Labels to apply to web requests that match the rule match statement.

AWS WAF applies fully qualified labels to matching web requests. A fully qualified label is the concatenation of a label namespace and a rule label. The rule's rule group or web ACL defines the label namespace.

Rules that run after this rule in the web ACL can match against these labels using a LabelMatchStatement .

For each label, provide a case-sensitive string containing optional namespaces and a label name, according to the following guidelines:

  • Separate each component of the label with a colon.
  • Each namespace or name can have up to 128 characters.
  • You can specify up to 5 namespaces in a label.
  • Don't use the following reserved words in your label specification: aws , waf , managed , rulegroup , webacl , regexpatternset , or ipset .

For example, myLabelName or nameSpace1:nameSpace2:myLabelName .