Skip to content

Resource: awsWafRule

Provides a WAF Rule Resource

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsWafIpsetIpset = new aws.wafIpset.WafIpset(this, "ipset", {
  ipSetDescriptors: [
    {
      type: "IPV4",
      value: "192.0.7.0/24",
    },
  ],
  name: "tfIPSet",
});
new aws.wafRule.WafRule(this, "wafrule", {
  depends_on: [`\${${awsWafIpsetIpset.fqn}}`],
  metricName: "tfWAFRule",
  name: "tfWAFRule",
  predicates: [
    {
      dataId: awsWafIpsetIpset.id,
      negated: false,
      type: "IPMatch",
    },
  ],
});

Argument Reference

The following arguments are supported:

  • metricName - (Required) The name or description for the Amazon CloudWatch metric of this rule. The name can contain only alphanumeric characters (A-Z, a-z, 0-9); the name can't contain whitespace.
  • name - (Required) The name or description of the rule.
  • predicates - (Optional) The objects to include in a rule (documented below).
  • tags - (Optional) Key-value map of resource tags. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Nested Blocks

predicates

See the WAF Documentation for more information.

Arguments

  • negated - (Required) Set this to false if you want to allow, block, or count requests based on the settings in the specified waf_byte_match_set, waf_ipset, aws_waf_size_constraint_set, aws_waf_sql_injection_match_set or aws_waf_xss_match_set. For example, if an IPSet includes the IP address 1920244, AWS WAF will allow or block requests based on that IP address. If set to true, AWS WAF will allow, block, or count requests based on all IP addresses except 1920244.
  • dataId - (Required) A unique identifier for a predicate in the rule, such as Byte Match Set ID or IPSet ID.
  • type - (Required) The type of predicate in a rule. Valid values: byteMatch, geoMatch, ipMatch, regexMatch, sizeConstraint, sqlInjectionMatch, or xssMatch.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ID of the WAF rule.
  • arn - The ARN of the WAF rule.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.

Import

WAF rules can be imported using the id, e.g.,

$ terraform import aws_waf_rule.example a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc