A company hosts a high-traffic API on a fleet of Amazon EC2 instances behind an Application Load Balancer (ALB). The ALB is integrated with an AWS WAF Web ACL that logs all web requests to an Amazon CloudWatch Logs log group. Due to the high volume of traffic, the CloudWatch Logs ingestion and storage costs have exceeded the budget. The security team requires that only requests that are explicitly blocked by the Web ACL be retained for analysis. Which action should the SysOps administrator take to meet these requirements with the least operational effort?
- AReplace the AWS WAF rules with Network Access Control List (NACL) rules at the subnet level to deny malicious IPs, and configure VPC Flow Logs to record the blocked traffic.
- BCreate a CloudWatch Logs metric filter that matches the WAF BLOCK action to record occurrences as a metric, and decrease the CloudWatch Logs log group retention period to 1 day.
- Configure a logging filter in the AWS WAF logging configuration. Define a filter rule that matches the BLOCK action to keep the logs, and set the default behavior to drop logs for all other requests.Answer
- DConfigure an AWS CloudTrail trail to log Application Load Balancer data events, write the logs to an Amazon S3 bucket, and apply a KMS key policy to restrict access while disabling AWS WAF logging.
Answer
Configure a logging filter in the AWS WAF logging configuration. Define a filter rule that matches the BLOCK action to keep the logs, and set the default behavior to drop logs for all other requests.
Configuring a logging filter directly in AWS WAF allows filtering out requests before they are sent to CloudWatch Logs. By matching the BLOCK action and keeping only those logs while dropping all others, ingestion and storage costs are minimized while satisfying the security requirement.
Step-by-Step Solution
Key Concept
AWS WAF Log Filtering