AWS WAF Web ACL
This page shows how to write Terraform and CloudFormation for AWS WAF Web ACL and write them securely.
aws_waf_web_acl (Terraform)
The Web ACL in AWS WAF can be configured in Terraform with the resource name aws_waf_web_acl
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_waf_web_acl" "default_action_type_set_to_block" {
name = "foo"
metric_name = "foo"
default_action {
type = "BLOCK"
resource "aws_waf_web_acl" "default_action_type_set_to_block" {
name = "foo"
metric_name = "foo"
default_action {
type = "BLOCK"
resource "aws_waf_web_acl" "default_action_type_set_to_block" {
name = "foo"
metric_name = "foo"
default_action {
type = "BLOCK"
resource "aws_waf_web_acl" "default_action_type_set_to_block" {
name = "foo"
metric_name = "foo"
default_action {
type = "BLOCK"
resource "aws_waf_web_acl" "my_waf" {
depends_on = [
aws_waf_ipset.ipset,
aws_waf_rule.wafrule,
]
name = "tfWebACL"
Parameters
-
arn
optional computed - string -
id
optional computed - string -
metric_name
required - string -
name
required - string -
tags
optional - map from string to string -
default_action
list block-
type
required - string
-
-
logging_configuration
list block-
log_destination
required - string -
redacted_fields
list block-
field_to_match
set block
-
-
-
rules
set block
Explanation in Terraform Registry
Provides a WAF Web ACL Resource
AWS::WAF::WebACL (CloudFormation)
The WebACL in WAF can be configured in CloudFormation with the resource name AWS::WAF::WebACL
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: AWS::WAF::WebACL
Properties:
Name: Master WebACL
DefaultAction:
Type: BLOCK
MetricName: MasterWebACL
Type: AWS::WAF::WebACL
Properties:
Name: Master WebACL
DefaultAction:
Type: BLOCK
MetricName: MasterWebACL
Type: AWS::WAF::WebACL
Properties:
Name: Master WebACL
DefaultAction:
Type: BLOCK
MetricName: MasterWebACL
Type: 'AWS::WAF::WebACL'
Properties:
DefaultAction:
Type: 'BLOCK'
Name: 'mywebacl'
MetricName: 'mywebacl'
Type: "AWS::WAF::WebACL"
Properties:
Name: !Sub "${Environment} ${Platform} Web ACL to block traffic based on defined rules. "
DefaultAction:
Type: "ALLOW"
MetricName: "WafWebACL"
"Type": "AWS::WAF::WebACL",
"Properties": {
"Name": "WebACL to with one rule",
"DefaultAction": {
"Type": "BLOCK"
},
"Type": "AWS::WAF::WebACL",
"Properties": {
"Name": "WebACL to with one rule",
"DefaultAction": {
"Type": "BLOCK"
},
"Type": "AWS::WAF::WebACL",
"Properties": {
"Name": "WebACL to with three rules",
"DefaultAction": {
"Type": "ALLOW"
},
"Type": "AWS::WAF::WebACL",
"Properties": {
"Name": "WebACL to with three rules",
"DefaultAction": {
"Type": "ALLOW"
},
"resourceType" : "AWS::WAF::WebACL",
"properties" : [ {
"propertyName" : "DefaultAction",
"propertyType" : "AWS::WAF::WebACL::Action",
"required" : true,
"propertyHref" : "aws-properties-waf-webacl-action.html"
Parameters
-
DefaultAction
required - WafAction -
MetricName
required - String -
Name
required - String -
Rules
optional - List of ActivatedRule
Explanation in CloudFormation Registry
Note This is AWS WAF Classic documentation. For more information, see AWS WAF Classic in the developer guide. For the latest version of AWS WAF , use the AWS WAFV2 API and see the AWS WAF Developer Guide. With the latest version, AWS WAF has a single set of endpoints for regional and global use. Contains the
Rules
that identify the requests that you want to allow, block, or count. In aWebACL
, you also specify a default action (ALLOW
orBLOCK
), and the action for eachRule
that you add to aWebACL
, for example, block requests from specified IP addresses or block requests from specified referrers. You also associate theWebACL
with a Amazon CloudFront distribution to identify the requests that you want AWS WAF to filter. If you add more than oneRule
to aWebACL
, a request needs to match only one of the specifications to be allowed, blocked, or counted.
Frequently asked questions
What is AWS WAF Web ACL?
AWS WAF Web ACL is a resource for WAF of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS WAF Web ACL?
For Terraform, the stelligent/config-lint, stelligent/config-lint and ffsclyh/config-lint source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the DanteInc/js-cloud-native-cookbook, paullewallencom/javascript-978-1-7884-7041-4 and PacktPublishing/JavaScript-Cloud-Native-Development-Cookbook source code examples are useful. See the CloudFormation Example section for further details.