I am trying to create a WebACL with cloudformation in order to protect the application API from abuse, the idea is throttle the API access for a maximum of 100 request for ip in 5 minutes.
For this purpose I have to use WAFv2 because the first version only seems to support:
- Static blacklisting
- Byte match
- Size constraint
- XSS
- SQLi
Documentation of WAFv2: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafv2-webacl.html
I wrote this as example:
AWSTemplateFormatVersion: 2010-09-09
Resources:
WebACL:
Type: 'AWS::WAFv2::WebACL'
Properties:
Name: WebAclLimit100
Scope: "REGIONAL"
DefaultAction:
Type: ALLOW
VisibilityConfig:
SampledRequestsEnabled: true
CloudWatchMetricsEnabled: true
MetricName: WebAcLimit100
But when I try to upload this on CloudFormation, the creation fails with this message:
Model validation failed (#: extraneous key [Type] is not permitted)
I think that the problem is on these lines:
DefaultAction:
Type: ALLOW
But I don't get how I can assign the DefaultAction without get a failure on CloudFormation, I tried many times (differently of course) and can't find the right way. No examples on internet for WAFv2, and the syntax for the first version of WAF don't seem compatible :(