Course contentsShow
← Cloud and Infrastructure
Lesson 210 of 2,9894. Cloud Networking BasicsFree lesson

Security Groups vs NACLs Use Cases

Compare when to use security groups versus network ACLs based on requirements for stateful vs stateless filtering.

Security Groups vs NACLs Use Cases

You'll learn: When to choose security groups versus network ACLs based on whether you need stateful or stateless filtering.

Now that you understand both security groups and NACLs, the key question is: which one should you use, and when?

The Core Decision: Stateful vs Stateless

Security groups are your primary defense tool. Because they're stateful, they automatically handle return traffic—perfect for most application scenarios. Use them when:

  • Protecting individual instances or groups of similar instances
  • You want simpler rule management (no need to worry about return paths)
  • You need to reference other security groups (like allowing database tier to accept connections only from app tier)
  • Managing dynamic port ranges would be complex

Network ACLs are your subnet-level boundary guards. Because they're stateless, you must explicitly allow both directions. Use them when:

  • You need explicit deny rules (security groups can't deny, only allow)
  • Adding defense-in-depth at the subnet boundary
  • Blocking specific IP addresses or ranges across an entire subnet
  • Regulatory compliance requires subnet-level controls
  • You need to filter traffic between subnets in the same VPC

Real-World Pattern

Best practice: Use security groups as your primary control, add NACLs for additional protection. Think of security groups as door locks on individual apartments, and NACLs as the building's main security gate.

For example: use a security group to allow your web servers to accept HTTPS traffic, then add a NACL to explicitly deny traffic from known malicious IP ranges at the subnet level.

Key Takeaway: Choose security groups for stateful, instance-level filtering in most cases; add NACLs when you need explicit denies, subnet-wide blocking, or defense-in-depth strategies.