teluzia.Cloud Engineer · Day 46
CHAPTER 07 · AWS VPC AND NETWORKING

Security groups vs NACLs

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

Evaluate one request and its reply through security groups and network ACLs. The mechanisms differ in attachment scope, rule types, ordering and state tracking. Your lab is a local rule-evaluation exercise that exposes a missing return-path permission without changing a real VPC. Security groups are associated with resources or their network interfaces and contain allow rules. Their combined rules are additive rather than ordered deny lists. Stateful tracking automatically permits responses to allowed traffic within documented connection-tracking behavior. Source-group references can express tier relationships without authorizing every internet address. A NACL applies at subnet boundaries and has inbound and outbound rules that may allow or deny. Rules are evaluated in ascending number, stopping at the first match. Each subnet has one NACL association. A broad low-number rule can hide a narrower later rule, so order is part of the policy.

Think of it this way

A security group is a state-aware doorman at the resource; a NACL is an ordered checkpoint at the subnet boundary.

TOPIC 01 / 03Step by step

Security-group semantics

Security groups are associated with resources or their network interfaces and contain allow rules. Their combined rules are additive rather than ordered deny lists. Stateful tracking automatically permits responses to allowed traffic within documented connection-tracking behavior. Source-group references can express tier relationships without authorizing every internet address. An app group allows TCP 8080 from the load-balancer group, while a database group allows TCP 5432 from the app group; neither needs public inbound database access for this two-tier path. Resource-level tier rules keep application access narrow and readable, letting reviewers understand which component may initiate a connection without maintaining broad public source ranges for private dependencies. Adding a “deny” security-group rule is not the supported model; remove unwanted allows or use another appropriate control rather than expecting ordered deny behavior from a group.

WORKED EXAMPLE
An app group allows TCP 8080 from the load-balancer group, while a database group allows TCP 5432 from the app group; neither needs public inbound database access for this two-tier path.
Why this matters

Resource-level tier rules keep application access narrow and readable, letting reviewers understand which component may initiate a connection without maintaining broad public source ranges for private dependencies.

A common trap

Adding a “deny” security-group rule is not the supported model; remove unwanted allows or use another appropriate control rather than expecting ordered deny behavior from a group.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Security-group semantics

Security groups are associated with resources or their network interfaces and contain allow rules. Their combined rules are additive rather than ordered deny lists. Stateful tracking automatically permits responses to allowed traffic within documented connection-tracking behavior. Source-group references can express tier relationships without authorizing every internet address. An app group allows TCP 8080 from the load-balancer group, while a database group allows TCP 5432 from the app group; neither needs public inbound database access for this two-tier path. Resource-level tier rules keep application access narrow and readable, letting reviewers understand which component may initiate a connection without maintaining broad public source ranges for private dependencies. Adding a “deny” security-group rule is not the supported model; remove unwanted allows or use another appropriate control rather than expecting ordered deny behavior from a group.

WORKED EXAMPLE
An app group allows TCP 8080 from the load-balancer group, while a database group allows TCP 5432 from the app group; neither needs public inbound database access for this two-tier path.

Why this matters

Resource-level tier rules keep application access narrow and readable, letting reviewers understand which component may initiate a connection without maintaining broad public source ranges for private dependencies.

A common trap

Adding a “deny” security-group rule is not the supported model; remove unwanted allows or use another appropriate control rather than expecting ordered deny behavior from a group.

NACL ordering and scope

A NACL applies at subnet boundaries and has inbound and outbound rules that may allow or deny. Rules are evaluated in ascending number, stopping at the first match. Each subnet has one NACL association. A broad low-number rule can hide a narrower later rule, so order is part of the policy. Rule 100 deny TCP from a source range wins before rule 200 allow the same traffic; swapping their numbers changes the result even though both textual rules remain present. Ordered evaluation explains counterintuitive blocked or allowed traffic and makes rule-number review as important as ports and addresses when diagnosing a subnet-boundary filter or designing a planned exception. Placing a broad allow before a narrower deny prevents that later deny from being evaluated for matching traffic; check the first matching rule rather than reading all rules as simultaneous votes.

WORKED EXAMPLE
Rule 100 deny TCP from a source range wins before rule 200 allow the same traffic; swapping their numbers changes the result even though both textual rules remain present.

Why this matters

Ordered evaluation explains counterintuitive blocked or allowed traffic and makes rule-number review as important as ports and addresses when diagnosing a subnet-boundary filter or designing a planned exception.

A common trap

Placing a broad allow before a narrower deny prevents that later deny from being evaluated for matching traffic; check the first matching rule rather than reading all rules as simultaneous votes.

Stateless return traffic

NACLs do not remember connections, so allowed requests need independently allowed responses. Reply destination ports can be client ephemeral ports rather than the original service port. Exact ephemeral ranges vary by client and environment. Model direction, source, destination and port separately instead of copying one inbound rule to outbound unchanged. A client using source port 50000 connects to server port 443; the reply targets client port 50000, so permitting only outbound destination 443 at the server subnet does not cover that reply under a stateless rule model. Full tuple reasoning prevents one-way connectivity and clarifies why a stateful security group can permit a response while a restrictive NACL still blocks it at the subnet boundary despite the original inbound request being allowed. Allowing the service destination port in both directions ignores response destination ports; trace the reply tuple and apply the documented ephemeral-port requirements for the actual clients involved rather than assuming all clients use the same range.

WORKED EXAMPLE
A client using source port 50000 connects to server port 443; the reply targets client port 50000, so permitting only outbound destination 443 at the server subnet does not cover that reply under a stateless rule model.

Why this matters

Full tuple reasoning prevents one-way connectivity and clarifies why a stateful security group can permit a response while a restrictive NACL still blocks it at the subnet boundary despite the original inbound request being allowed.

A common trap

Allowing the service destination port in both directions ignores response destination ports; trace the reply tuple and apply the documented ephemeral-port requirements for the actual clients involved rather than assuming all clients use the same range.

KEEP THESE WITH YOU

Today’s takeaways

Use tier-specific group allows.

Review NACL first-match ordering.

Model stateless reply ports explicitly.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed