Network Security Automation: WAF, Shield, Network Firewall and Firewall Manager
Overview
Network security on AWS is built in layers. Security groups and network ACLs control traffic at the instance and subnet level, AWS WAF inspects HTTP requests at CloudFront, ALB, API Gateway and AppSync, Shield absorbs DDoS attacks, and Network Firewall filters traffic inside and between VPCs. Firewall Manager applies these controls across an entire organisation.
Imagine a castle. The moat and outer wall (Shield and CloudFront) absorb the siege, gate guards (WAF) inspect each visitor's papers, patrols inside the courtyard (Network Firewall) watch lateral movement, and the locks on individual rooms (security groups) are the last line. No layer is sufficient alone.
DOP-C02 does not ask for deep routing theory; it asks which service solves a given threat and how to deploy and enforce it automatically in many accounts and Regions.
Key Concepts
- Security groups are stateful, allow-only and attach to ENIs; network ACLs are stateless, numbered, allow and deny rules at the subnet level.
- AWS WAF web ACLs contain rules (managed rule groups, rate-based rules, IP sets, geo match, bot control) and attach to CloudFront, ALB, API Gateway, AppSync and Cognito.
- Shield Standard is automatic and free; Shield Advanced adds DDoS response team, cost protection, advanced detection and health-based detection for specific resources.
- AWS Network Firewall is a managed stateful and stateless firewall with Suricata-compatible rules, domain filtering and TLS inspection, deployed in dedicated firewall subnets.
- Firewall Manager centrally configures WAF, Shield Advanced, security group policies, Network Firewall and Route 53 Resolver DNS Firewall for accounts in an organisation.
- VPC endpoints and PrivateLink keep traffic to AWS services and partner services off the internet; endpoint policies restrict what can be accessed.
- Route 53 Resolver DNS Firewall blocks queries to malicious domains and prevents DNS exfiltration.
- Centralised inspection uses a Transit Gateway with an inspection VPC (appliance mode) hosting Network Firewall.
Detailed Notes
Choosing the right layer
| Threat | Best control | Notes |
|---|---|---|
| SQL injection, XSS, bad bots | AWS WAF managed rules | Attach to ALB/CloudFront/API Gateway |
| HTTP flood from many IPs | WAF rate-based rule + Shield Advanced | Rate rules aggregate by IP or custom keys |
| Volumetric L3/L4 DDoS | Shield (Standard/Advanced) with CloudFront, Route 53, Global Accelerator | Edge services absorb attacks |
| Block one malicious IP at subnet level | Network ACL deny rule | Stateless; remember return traffic |
| Allow only specific outbound domains | Network Firewall domain list or Route 53 DNS Firewall | Egress filtering |
| Prevent lateral movement | Security groups referencing other groups | Least privilege between tiers |
| Enforce rules across 200 accounts | Firewall Manager policies | Needs Organizations and a delegated administrator |
| Private access to AWS APIs | Gateway/interface VPC endpoints | Add endpoint policies |
Security groups versus network ACLs
| Feature | Security group | Network ACL |
|---|---|---|
| State | Stateful | Stateless |
| Rule types | Allow only | Allow and deny |
| Evaluation | All rules together | In rule-number order |
| Applies to | ENI/instance | Subnet |
| Reference other resources | Yes (security group IDs) | No (CIDR only) |
WAF deployed as code
WebACL:
Type: AWS::WAFv2::WebACL
Properties:
Scope: REGIONAL
DefaultAction: { Allow: {} }
VisibilityConfig:
SampledRequestsEnabled: true
CloudWatchMetricsEnabled: true
MetricName: web-acl
Rules:
- Name: aws-common
Priority: 0
OverrideAction: { None: {} }
Statement:
ManagedRuleGroupStatement: { VendorName: AWS, Name: AWSManagedRulesCommonRuleSet }
VisibilityConfig: { SampledRequestsEnabled: true, CloudWatchMetricsEnabled: true, MetricName: common }
- Name: rate-limit
Priority: 1
Action: { Block: {} }
Statement:
RateBasedStatement: { Limit: 2000, AggregateKeyType: IP }
VisibilityConfig: { SampledRequestsEnabled: true, CloudWatchMetricsEnabled: true, MetricName: rate }
Start new rules in Count mode, review sampled requests and WAF logs (delivered to S3, CloudWatch Logs or Firehose), then switch to Block. WAF scope for CloudFront must be created in us-east-1.
Firewall Manager at organisation scale
- Enable Organizations integration and AWS Config in all accounts.
- Designate a Firewall Manager administrator account.
- Create policies (WAF, Shield Advanced, security group audit/usage, Network Firewall, DNS Firewall) scoped by OU, account or resource tags.
- New accounts and resources are automatically brought into compliance, with optional auto-remediation.
Centralised egress and inspection
Workload VPCs -> Transit Gateway -> Inspection VPC (Network Firewall) -> NAT -> Internet Gateway
Enable appliance mode on the inspection VPC attachment so both directions of a flow traverse the same AZ. Distributed alternative: a firewall endpoint in each VPC. Route tables send traffic through the firewall endpoint; forgetting the return route is the common misconfiguration.
Troubleshooting
- Blocked traffic that "should work": check the NACL ephemeral port return range (1024-65535), security group references, and VPC Flow Logs REJECT records.
- WAF false positives: inspect sampled requests, add rule exclusions or scope-down statements.
- Network Firewall dropping legitimate traffic: examine alert and flow logs, and the default stateful action (drop established vs alert).
Real World Example
Scenario: an e-commerce site is attacked by SQL injection attempts and a botnet that floods the login endpoint. The team attaches a WAF web ACL with the AWS managed Core and SQL database rule groups plus a rate-based rule to CloudFront, and subscribes the account to Shield Advanced.
For compliance, all outbound traffic from private subnets must go through domain allow-listing. A central inspection VPC with Network Firewall enforces it, and Firewall Manager deploys the same WAF and DNS Firewall policies to every new account in the Production OU.
Architecture Diagram
Edge protection, application-layer filtering and network inspection managed centrally.
- 1Shield and edge services absorb volumetric attacks.
- 2WAF evaluates managed, rate-based and custom rules on each HTTP request.
- 3The ALB forwards allowed requests into private subnets.
- 4Security groups and network ACLs restrict tier-to-tier traffic.
- 5Firewall Manager keeps the WAF and firewall policies consistent across accounts.
Best Practices
- ✓Layer CloudFront + WAF + Shield + security groups instead of relying on a single control.
- ✓Deploy WAF rules in Count mode first, log requests, then enforce.
- ✓Use Firewall Manager and Organizations to guarantee baseline protection in every account.
- ✓Reference security groups rather than CIDRs between tiers and avoid 0.0.0.0/0 on admin ports.
- ✓Use VPC endpoints with endpoint policies to keep AWS API traffic private.
Common Interview Questions
Exam Tips
DOP-C02 focus
- "Block SQL injection on ALB" = WAF managed rule group, not a network ACL.
- "Enforce firewall rules across all accounts automatically" = Firewall Manager.
- "Stateless, deny rule at subnet level" = network ACL.
- "Filter egress by domain name" = Network Firewall or DNS Firewall.
Finished this lesson?
0 of 44 lessons done · 0% of the course

