How do I configure AWS WAF comprehensive logging to store logs in Amazon S3?
Last updated: 2019-11-19
I've set up AWS WAF, and now I need to configure comprehensive logging to store logs in Amazon Simple Storage Service (Amazon S3). How can I do this?
You can enable comprehensive logging on a web access control list (web ACL) using an Amazon Kinesis Data Firehose stream destined to an Amazon S3 bucket in the same Region. To do so, you must use three AWS services:
- AWS WAF to create the logs
- Kinesis Data Firehose to receive the logs
- Amazon S3 to store the logs
Note: AWS WAF, Kinesis Data Firehose, and Amazon S3 must be running in the same Region.
Create a Kinesis Data Firehose
- Open the Kinesis console.
- In the navigation bar, choose the Region where your web ACL is stored.
- In the navigation pane, choose Data Firehose.
- Choose Create Delivery Stream.
- For Delivery stream name, enter a name for your delivery stream. The name must start with aws-waf-logs- and end with the suffix of your choice. For example, aws-waf-logs-demo.
- For Source, keep the default Direct PUT or other sources selected. Then, choose Next.
- Keep the default options for the following settings:
Record transformation (Disabled)
Record format conversion (Disabled)
- Choose Next.
- For Destination, choose Amazon S3.
- In the S3 destination section, choose Create new.
- For S3 bucket name, enter a name. For uniformity, you can use the same name that you used for the delivery stream you created in step 4.
- Choose the Region where the AWS WAF logs will be stored.
- Choose Create S3 bucket.
- (Optional) Configure an S3 prefix and an Error prefix.
Note: Custom prefixes are helpful when your bucket is shared with other logs.
- Choose Next.
- You can keep the default options for the following settings:
Buffer size (5)
Buffer interval (300)
S3 compression (Disabled)
S3 encryption (Disabled)
- (Optional) Configure tags, if needed.
- For IAM role, choose Create new or choose.
- For Role Name, enter a descriptive name. For example, firehose_to_s3-waflogs-demo.
- Choose Allow, and then choose Next.
- Review the configuration, and then choose Create delivery stream.
Associate AWS WAF with the Kinesis Data Firehose
- Open the AWS WAF console.
- In the navigation pane, choose Web ACLs.
- For Filter, choose the Region where your web ACL was created.
- Choose the relevant web ACL from the resulting list, and then choose Logging.
- Choose Enable Logging.
- For Amazon Kinesis Data Firehose, choose the delivery stream that you created above.
- (Optional) Configure any fields that should be redacted from the logs.
- Choose Create. All AWS WAF logs are stored in the Amazon S3 bucket for analysis.
Note: One AWS WAF log is equivalent to one Kinesis Data Firehose record. If you typically receive 10,000 requests per second, set a 10,000 record per second limit in Kinesis Data Firehose to enable full logging. Otherwise, AWS WAF doesn't record all logs. For more information, see Amazon Kinesis Data Firehose Limits.