Skip to main content
Skip to main content
Still in beta — questions, comments or suggestions? aramb@aramb.dev

Security Groups vs NACLs

Understand the two layers of VPC network security — stateful security groups at the instance level and stateless NACLs at the subnet level.

15 min
Introductory

Learning outcomes

By the end of this lesson, you will be able to:

  1. Explain the difference between stateful and stateless firewalls.
  2. Describe how security groups work at the instance level.
  3. Describe how NACLs work at the subnet level.
  4. Compare security groups and NACLs in a side-by-side table.
  5. Choose the correct tool for common exam scenarios.

Quick recap: security groups

You met security groups in Module 4.1. Here's the essential recap:

  • Level: Attached to individual instances (ENIs).
  • Rules: Allow-only — you cannot create deny rules.
  • State: Stateful — if inbound traffic is allowed, the response is automatically allowed out.
  • Default: No inbound rules (all blocked), one outbound rule allowing all traffic.

Tip

Think of a security group as a bouncer at a door. The bouncer only has an invite list (allow rules). If you're not on the list, you don't get in. And if you were let in, you're automatically allowed to leave.


Introducing NACLs

A Network Access Control List (NACL) is a firewall at the subnet level. Every subnet in your VPC is associated with exactly one NACL.

How NACLs differ from security groups

  • Level: Applied to the entire subnet — all traffic entering or leaving the subnet passes through the NACL.
  • Rules: Support both allow and deny rules.
  • State: Stateless — inbound and outbound rules are evaluated independently. If you allow inbound traffic, you must also explicitly allow the outbound response.
  • Evaluation: Rules are evaluated in number order (lowest first). The first matching rule wins.

Default NACL vs custom NACL

Default NACLCustom NACL
Created withEvery new VPCManually by you
Default behaviorAllows all inbound and outbound trafficDenies all inbound and outbound traffic
Use caseWorks out of the boxRequires explicit rules before any traffic flows

Warning

If you create a custom NACL and associate it with a subnet without adding rules, all traffic will be blocked. This is a common mistake that breaks connectivity.


NACL rule evaluation

NACL rules are processed in ascending numerical order. The first rule that matches the traffic is applied, and no further rules are checked.

Rule #TypeProtocolPortSourceAction
100InboundTCP4430.0.0.0/0Allow
110InboundTCP800.0.0.0/0Allow
120InboundTCP22203.0.113.5/32Allow
200InboundAllAll198.51.100.0/24Deny
*InboundAllAll0.0.0.0/0Deny
  • Rule 100 is checked first. If the traffic matches, it's allowed — done.
  • Rule 200 denies a specific IP range.
  • The * (asterisk) rule is the catch-all — if no numbered rule matches, this rule denies the traffic.

Note

Exam tip: Lower-numbered rules are evaluated first. If you need to block a specific IP, place the deny rule with a lower number than any allow rule that might match the same traffic.


Side-by-side comparison

FeatureSecurity GroupNACL
Operates atInstance (ENI) levelSubnet level
StateStatefulStateless
Rule typesAllow onlyAllow and Deny
Rule evaluationAll rules evaluated togetherRules evaluated in number order (first match wins)
Default inboundAll deniedDefault NACL: all allowed; Custom NACL: all denied
Default outboundAll allowedDefault NACL: all allowed; Custom NACL: all denied
AssociationOne or more instancesOne subnet (each subnet has exactly one NACL)

When to use each — exam patterns

Use a security group when:

  • You need to control access per instance (e.g., allow only your web servers to talk to your database).
  • You want to reference other security groups as sources (e.g., "allow traffic from the web-server security group").

Use a NACL when:

  • You need to block a specific IP address or range — security groups cannot deny traffic.
  • You want a subnet-wide rule that applies to all resources in that subnet.
  • You need an additional layer of defense alongside security groups (defense in depth).

Tip

On the CCP exam, if a question mentions blocking or denying specific traffic, the answer is almost always a NACL. Security groups are allow-only.


Summary

Security groups and NACLs are complementary layers of network security:

  • Security groups = instance-level, stateful, allow-only.
  • NACLs = subnet-level, stateless, allow + deny.

Together they form a defense-in-depth strategy. Most production VPCs use both.


Knowledge Check

Knowledge Check
1 / 4

Which firewall type supports deny rules?

Next lesson

Lesson 3: Amazon Route 53 — DNS and Routing