How to Configure AWS WAF with Application Load Balancer
Learn how to protect your AWS applications by attaching AWS WAF to an Application Load Balancer with managed rule groups.
AWS WAF integrates natively with Application Load Balancer (ALB) to protect your web applications from common exploits and attacks.
This guide covers creating a Web ACL, attaching it to your ALB, and configuring managed rule groups for comprehensive protection.
Prerequisites
- An AWS account with appropriate IAM permissions
- An existing Application Load Balancer
- Basic familiarity with AWS Console
Step-by-Step Guide
Navigate to AWS WAF Console
Open the AWS Console and navigate to AWS WAF:
- Sign into the AWS Console
- Search for "WAF" in the services search bar
- Select "AWS WAF" from the results
The standard console opens at https://console.aws.amazon.com/wafv2/homev2 and uses the "web ACL" terminology this guide follows. AWS is also rolling out a new console experience at https://console.aws.amazon.com/wafv2-pro that renames the object to a "protection pack (web ACL)" and restructures the creation wizard around App category, Traffic source, and protection levels (Recommended, Essentials, You build it). If you land in the new experience, the concepts map directly, but some labels and the wizard flow differ from the steps below.
Create a Web ACL
Create a new Web ACL to contain your firewall rules:
- Click "Create web ACL"
- Enter a name (e.g., "production-web-acl")
- Under "Resource type", select "Regional resources" (this category covers ALB, API Gateway, and other regional resources; the alternative is "Amazon CloudFront distributions")
- Select your region
- Click "Next"
Add AWS Managed Rules
Add managed rule groups for immediate protection:
- Click "Add rules" > "Add managed rule groups"
- Expand "AWS managed rule groups"
- Enable "Core rule set" (protects against OWASP Top 10)
- Enable "Known bad inputs" (blocks requests with known malicious patterns)
- Enable "SQL database" if your app uses SQL
- Click "Add rules"
Configure Default Action
Set what happens to requests that don't match any rules:
- For "Default web ACL action for requests that don't match any rules", select "Allow"
- This means only explicitly blocked traffic is denied
- Click "Next"
Set Rule Priority
Rules are evaluated in order. AWS processes them top to bottom:
- Drag rules to set priority (highest priority at top)
- Generally, put block rules before allow rules
- Click "Next"
Associate ALB Resources
Attach the Web ACL to your Application Load Balancer:
- Click "Add AWS resources"
- Select "Application Load Balancer"
- Check the box next to your ALB
- Click "Add"
- Click "Next" and then "Create web ACL"
Note: When you associate an Application Load Balancer with a web ACL, AWS WAF automatically enables resource-level DDoS protection for that ALB.
Enable Logging (Recommended)
Enable logging to monitor blocked requests:
- Select your Web ACL
- Go to the "Logging and metrics" tab
- Click "Enable logging"
- Choose a destination (CloudWatch Logs, Amazon S3, or Amazon Data Firehose)
- Click "Save"
Note: Amazon Kinesis Data Firehose was renamed Amazon Data Firehose in February 2024, so the AWS WAF console and docs now list this destination as "Firehose" / "Amazon Data Firehose delivery stream".
# Example CloudWatch Logs group name
aws-waf-logs-production-web-acl
Conclusion & Next Steps
Your ALB is now protected by AWS WAF with managed rule groups. The WAF will inspect all incoming HTTP/HTTPS traffic and block known attack patterns.
Next steps:
- Monitor the WAF dashboard for blocked and counted requests, and switch rule groups from Count to Block once you have confirmed they do not affect legitimate traffic
- Set up CloudWatch alarms for high block rates
- Consider adding rate-based rules for application-layer rate limiting; note that associating the ALB already enabled resource-level DDoS protection automatically
- Review and tune rules based on your application's needs
Troubleshooting
Legitimate traffic being blocked
Check CloudWatch Logs or S3 logs to identify the rule causing blocks. You can set specific rules to "Count" mode instead of "Block" while you investigate.
Can't find my ALB when associating
Make sure you're in the same AWS region as your ALB. Web ACLs are regional resources.
High costs after enabling WAF
Review the number of rules and request volume. Consider consolidating rules or using capacity units more efficiently.
Frequently Asked Questions
What's the difference between Web ACL and rule groups?
A Web ACL is a container that holds rules and rule groups. Rule groups are reusable collections of rules that you can add to multiple Web ACLs. AWS managed rule groups are pre-configured by AWS and updated automatically.
How much does AWS WAF cost?
AWS WAF charges based on Web ACLs ($5/month each), rules ($1/month each), and requests ($0.60 per million). Managed rule groups may have additional costs. Monitor your usage with AWS Cost Explorer.