aws-cdk-lib.aws_wafv2.CfnWebACL.RuleActionProperty

interface RuleActionProperty

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

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

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

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_wafv2 as wafv2 } from 'aws-cdk-lib';
const ruleActionProperty: wafv2.CfnWebACL.RuleActionProperty = {
  allow: {
    customRequestHandling: {
      insertHeaders: [{
        name: 'name',
        value: 'value',
      }],
    },
  },
  block: {
    customResponse: {
      responseCode: 123,

      // the properties below are optional
      customResponseBodyKey: 'customResponseBodyKey',
      responseHeaders: [{
        name: 'name',
        value: 'value',
      }],
    },
  },
  captcha: {
    customRequestHandling: {
      insertHeaders: [{
        name: 'name',
        value: 'value',
      }],
    },
  },
  challenge: {
    customRequestHandling: {
      insertHeaders: [{
        name: 'name',
        value: 'value',
      }],
    },
  },
  count: {
    customRequestHandling: {
      insertHeaders: [{
        name: 'name',
        value: 'value',
      }],
    },
  },
};

Properties

NameTypeDescription
allow?IResolvable | AllowActionPropertyInstructs AWS WAF to allow the web request.
block?IResolvable | BlockActionPropertyInstructs AWS WAF to block the web request.
captcha?IResolvable | CaptchaActionPropertySpecifies that AWS WAF should run a CAPTCHA check against the request:.
challenge?IResolvable | ChallengeActionPropertyInstructs AWS WAF to run a Challenge check against the web request.
count?IResolvable | CountActionPropertyInstructs AWS WAF to count the web request and then continue evaluating the request using the remaining rules in the web ACL.

allow?

Type: IResolvable | AllowActionProperty (optional)

Instructs AWS WAF to allow the web request.


block?

Type: IResolvable | BlockActionProperty (optional)

Instructs AWS WAF to block the web request.


captcha?

Type: IResolvable | CaptchaActionProperty (optional)

Specifies that AWS WAF should run a CAPTCHA check against the request:.

  • If the request includes a valid, unexpired CAPTCHA token, AWS WAF allows the web request inspection to proceed to the next rule, similar to a CountAction .
  • If the request doesn't include a valid, unexpired CAPTCHA token, AWS WAF discontinues the web ACL evaluation of the request and blocks it from going to its intended destination.

AWS WAF generates a response that it sends back to the client, which includes the following:

  • The header x-amzn-waf-action with a value of captcha .
  • The HTTP status code 405 Method Not Allowed .
  • If the request contains an Accept header with a value of text/html , the response includes a CAPTCHA challenge.

You can configure the expiration time in the CaptchaConfig ImmunityTimeProperty setting at the rule and web ACL level. The rule setting overrides the web ACL setting.

This action option is available for rules. It isn't available for web ACL default actions.


challenge?

Type: IResolvable | ChallengeActionProperty (optional)

Instructs AWS WAF to run a Challenge check against the web request.


count?

Type: IResolvable | CountActionProperty (optional)

Instructs AWS WAF to count the web request and then continue evaluating the request using the remaining rules in the web ACL.