AWS WAF V2 Regex Pattern Set
This page shows how to write Terraform and CloudFormation for AWS WAF V2 Regex Pattern Set and write them securely.
aws_wafv2_regex_pattern_set (Terraform)
The Regex Pattern Set in AWS WAF V2 can be configured in Terraform with the resource name aws_wafv2_regex_pattern_set
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_wafv2_regex_pattern_set" "invalid_url" {
name = "invalid_url"
scope = "REGIONAL"
regular_expression {
regex_string = "admin"
resource "aws_wafv2_regex_pattern_set" "blockedURL"{
name = "blocked-URL"
scope = "REGIONAL"
# blocks of regular expression patterns that you want AWS WAF to search for
regular_expression {
resource "aws_wafv2_regex_pattern_set" "deny_eb_cname_regex" {
name = "eb-cnames"
description = "EB CNAME regex pattern set"
scope = "REGIONAL"
regular_expression {
resource "aws_wafv2_regex_pattern_set" "blockedURL"{
name = "blocked-URL"
scope = "REGIONAL"
# blocks of regular expression patterns that you want AWS WAF to search for
regular_expression {
resource "aws_wafv2_regex_pattern_set" "this" {
description = var.description
name = var.name
scope = var.scope
tags = var.tags
Parameters
-
arn
optional computed - string -
description
optional - string -
id
optional computed - string -
lock_token
optional computed - string -
name
required - string -
scope
required - string -
tags
optional - map from string to string -
regular_expression
set block-
regex_string
required - string
-
Explanation in Terraform Registry
Provides an AWS WAFv2 Regex Pattern Set Resource
AWS::WAFv2::RegexPatternSet (CloudFormation)
The RegexPatternSet in WAFv2 can be configured in CloudFormation with the resource name AWS::WAFv2::RegexPatternSet
. The following sections describe 9 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::WAFv2::RegexPatternSet
Description: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-regexpatternset.html
Properties:
Scope: !Ref 'Scope'
Outputs:
Arn:
Type: AWS::WAFv2::RegexPatternSet
Description: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-regexpatternset.html
Properties:
Scope: !Ref 'Scope'
Outputs:
Arn:
Type: AWS::WAFv2::RegexPatternSet
Description: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-regexpatternset.html
Properties:
Scope: !Ref 'Scope'
Outputs:
Arn:
Type: AWS::WAFv2::RegexPatternSet
Description: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-regexpatternset.html
Properties:
Scope: !Ref 'Scope'
Outputs:
Arn:
Type: AWS::WAFv2::RegexPatternSet
Description: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-regexpatternset.html
Properties:
Scope: !Ref 'Scope'
Outputs:
Arn:
"AWS::WAFv2::RegexPatternSet": {
"Type": "AWS::WAFv2::RegexPatternSet",
"Properties": {}
},
"AWS::Batch::JobDefinition": {
"Type": "AWS::Batch::JobDefinition",
"AWS::WAFv2::RegexPatternSet": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-regexpatternset.html",
"Properties": {
"Description": {
"Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-regexpatternset.html#cfn-wafv2-regexpatternset-description",
"UpdateType": "Mutable",
"Type": "AWS::WAFv2::RegexPatternSet",
"Properties": {
"Description": "Regex Pattern Set for the Bots",
"Name": "Bots",
"RegularExpressionList": [
"^.+(guzzlehttp|trovitbot|phantomjs|wget).+"
"resourceType": "AWS::WAFv2::RegexPatternSet",
"filePath": null
},
{
"resourceType": "AWS::WAFv2::IPSet",
"filePath": null
Parameters
-
Description
optional - String -
Name
optional - String -
RegularExpressionList
required - List -
Scope
required - String -
Tags
optional - List of Tag
Explanation in CloudFormation Registry
Note This is the latest version of AWS WAF, named AWS WAFV2, released in November, 2019. For information, including how to migrate your AWS WAF resources from the prior release, see the AWS WAF Developer Guide. Use a
RegexPatternSet
to have AWS WAF inspect a web request component for a specific set of regular expression patterns. You use a regex pattern set by providing its Amazon Resource Name (ARN) to the rule statementRegexPatternSetReferenceStatement
, when you add a rule to a rule group or web ACL.
Frequently asked questions
What is AWS WAF V2 Regex Pattern Set?
AWS WAF V2 Regex Pattern Set is a resource for WAF V2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS WAF V2 Regex Pattern Set?
For Terraform, the javyak/nw_public_cloud, ipspace/pubcloud and mikeapted/tf-shared-alb-rules-waf source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the awslabs/aws-service-catalog-products, awslabs/aws-service-catalog-products and awslabs/aws-service-catalog-products source code examples are useful. See the CloudFormation Example section for further details.