Skip to content

Setup AWS WAF (Web Application Firewall)

MCatherine edited this page Jul 26, 2023 · 6 revisions

Create ACL for WAF

  • Go to the AWS WAF service, select the Web ACLs on the left, and then "Create web ACL"
Screen Shot 2023-07-26 at 2 13 44 PM * The first step is creating the name, and select the resource type. We'll create two ACLs, one for CloudFont which global region, one for APIGateway with Canada region. The screenshot shows the example for the APIGateway ACL Screen Shot 2023-07-26 at 1 58 49 PM
  • And then we need to set some security rules. For our starting point, we'll select the following rules from the AWS managed rule groups:
Screen Shot 2023-07-26 at 1 59 04 PM Screen Shot 2023-07-26 at 1 59 57 PM * Default web ACL action is "allow" Screen Shot 2023-07-26 at 2 00 23 PM * And then we just click next until finish create this ACL

Setup AWS WAF in CloudFont

  • Find our cloudfont distribution click "Edit" for setting
Screen Shot 2023-07-26 at 2 37 00 PM * Choose the AWS WAF we created for cloudfont and then save changes Screen Shot 2023-07-26 at 2 38 11 PM

Setup AWS WAF in ApiGateway.

  • Go to "Stages" and "Settings" for our current version, select the AWS WAF we created for api gateway
Screen Shot 2023-07-26 at 2 39 02 PM

How to test the WAF

It's hard to test that for CloudFont because of the cache. We could only test the api gateway. So change the default web ACL action from "allow" to "block", and verify the api web page is no longer accessible, and the api call is not working anymore.

Clone this wiki locally