AWS::WAFv2::WebACL - AWS CloudFormation

AWS::WAFv2::WebACL

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 an AWS::WAFv2::WebACL to define a collection of rules to use to inspect and control web requests. Each rule has an action defined (allow, block, or count) for requests that match the statement of the rule. In the web ACL, you assign a default action to take (allow, block) for any request that does not match any of the rules. The rules in a web ACL can contain rule statements that you define explicitly and rule statements that reference rule groups and managed rule groups. You can associate a web ACL with one or more AWS resources to protect. The resources can be an Amazon CloudFront distribution, an Amazon API Gateway API, or an Application Load Balancer.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::WAFv2::WebACL", "Properties" : { "DefaultAction" : DefaultAction, "Description" : String, "Name" : String, "Rules" : [ Rule, ... ], "Scope" : String, "Tags" : [ Tag, ... ], "VisibilityConfig" : VisibilityConfig } }

YAML

Type: AWS::WAFv2::WebACL Properties: DefaultAction: DefaultAction Description: String Name: String Rules: - Rule Scope: String Tags: - Tag VisibilityConfig: VisibilityConfig

Properties

DefaultAction

The action to perform if none of the Rules contained in the WebACL match.

Required: Yes

Type: DefaultAction

Update requires: No interruption

Description

A friendly description of the Web ACL. You cannot change the description of a Web ACL after you create it.

Required: No

Type: String

Minimum: 1

Maximum: 256

Pattern: ^[\w+=:#@/\-,\.][\w+=:#@/\-,\.\s]+[\w+=:#@/\-,\.]$

Update requires: No interruption

Name

A friendly name of the Web ACL. You cannot change the name of a Web ACL after you create it.

Required: No

Type: String

Minimum: 1

Maximum: 128

Pattern: ^[\w\-]+$

Update requires: No interruption

Rules

The Rule statements used to identify the 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.

Required: No

Type: List of Rule

Update requires: No interruption

Scope

Specifies whether this is for an AWS CloudFront distribution or for a regional application. A regional application can be an Application Load Balancer (ALB) or an API Gateway stage. Valid Values are CLOUDFRONT and REGIONAL.

Note

For CLOUDFRONT, you must create your WAFv2 resources in the US East (N. Virginia) Region, us-east-1.

Required: Yes

Type: String

Update requires: No interruption

Tags

Key:value pairs associated with an AWS resource. The key:value pair can be anything you define. Typically, the tag key represents a category (such as "environment") and the tag value represents a specific value within that category (such as "test," "development," or "production"). You can add up to 50 tags to each AWS resource.

Required: No

Type: List of Tag

Update requires: No interruption

VisibilityConfig

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

Required: Yes

Type: VisibilityConfig

Update requires: No interruption

Return Values

Ref

The Ref for the resource, containing the resource name, physical ID, and scope, formatted as follows: name|id|scope.

For example: my-webacl-name|1234a1a-a1b1-12a1-abcd-a123b123456|REGIONAL

Fn::GetAtt

Arn

The Amazon Resource Name (ARN) of the web ACL.

Capacity

The current web ACL capacity (WCU) usage by the web ACL.

Id

The ID of the web ACL.

Examples

Create a web ACL

The following shows an example web ACL specification.

YAML

Description: Create WebACL example Resources: ExampleWebACL: Type: AWS::WAFv2::WebACL Properties: Name: ExampleWebACL Scope: REGIONAL Description: This is an example WebACL DefaultAction: Allow: {} VisibilityConfig: SampledRequestsEnabled: true CloudWatchMetricsEnabled: true MetricName: ExampleWebACLMetric Rules: - Name: RuleWithAWSManagedRules Priority: 0 OverrideAction: Count: {} VisibilityConfig: SampledRequestsEnabled: true CloudWatchMetricsEnabled: true MetricName: RuleWithAWSManagedRulesMetric Statement: ManagedRuleGroupStatement: VendorName: AWS Name: AWSManagedRulesCommonRuleSet ExcludedRules: [] - Name: BlockXssAttack Priority: 1 Action: Block: {} VisibilityConfig: SampledRequestsEnabled: true CloudWatchMetricsEnabled: true MetricName: BlockXssAttackMetric Statement: XssMatchStatement: FieldToMatch: AllQueryArguments: {} TextTransformations: - Priority: 1 Type: NONE

JSON

"Description": "Create WebACL example", "Resources": { "ExampleWebACL": { "Type": "AWS::WAFv2::WebACL", "Properties": { "Name": "ExampleWebACL1", "Scope": "REGIONAL", "Description": "This is an example WebACL", "DefaultAction": { "Allow": {} }, "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "ExampleWebACLMetric" }, "Rules": [ { "Name": "RuleWithAWSManagedRules", "Priority": 0, "OverrideAction": { "Count": {} }, "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "RuleWithAWSManagedRulesMetric" }, "Statement": { "ManagedRuleGroupStatement": { "VendorName": "AWS", "Name": "AWSManagedRulesCommonRuleSet", "ExcludedRules": [] } } }, { "Name": "BlockXssAttack", "Priority": 1, "Action": { "Block": {} }, "VisibilityConfig": { "SampledRequestsEnabled": true, "CloudWatchMetricsEnabled": true, "MetricName": "BlockXssAttackMetric" }, "Statement": { "XssMatchStatement": { "FieldToMatch": { "AllQueryArguments": {} }, "TextTransformations": [ { "Priority": 1, "Type": "NONE" } ] } } } ] } } }