This CDK template will deploy a WebACL that includes the baseline rule group of AWS managed rules and a rate-based rule. Also, create a CloudWatch logs group and CloudWatch dashboard for AWS WAF.
WebACL includes the following rules set as COUNT mode:
- Core rule set (CRS) managed rule group
- Known bad inputs managed rule group
- Rate-based rule for All requests
CloudWatch dashboard is created by the CloudFormation template in the CDK. the dashboard includes the following widgets:
- Allowed vs Blocked Requests
- All Counted Requests
- Top Terminating Rules
- Top Countries
- Top IP addresses
- Top User-agents
- Top Counted URIs
- Top Blocked URIs
- Counted Requests
- Blocked Requests
- AWS profile configured
- AWS CDK installed see here for instructions
Run
npm install
cdk bootstrap -c webaclName={Your WebACL name}
cdk deploy -c webaclName={Your WebACL name}
This CDK template does not include the AWS resource to associate with WebACL. Please associate your AWS resource (CloudFront) to the WebACL created by this template. see here for instructions
Before removing the stack, you will need to disassociate the AWS resource from WebACL manually.
Run
cdk destroy -c webaclName={Your WebACL name}