AWS Security Groups vs. Network ACLs: Understanding the Difference
Security Groups and Network ACLs are two important layers of network security in AWS. In this article, I explain their main differences and when to use each one in a VPC.
# AWS Security Groups vs. Network ACLs: Understanding the Difference
As I continue learning AWS and preparing for the AWS Certified Solutions Architect – Associate certification, one topic that initially seemed confusing was the difference between Security Groups and Network ACLs.
Both are used to control network traffic inside an Amazon VPC, but they work in different ways.
Understanding this difference is important not only for the certification exam, but also when designing secure architectures in AWS.
## What is a Security Group?
A Security Group acts as a virtual firewall for AWS resources such as Amazon EC2 instances.
It controls which traffic is allowed to enter or leave a resource.
For example, imagine that we have a web server running on an EC2 instance.
We could configure the Security Group to allow:
- HTTPS traffic on port 443 from the Internet
- SSH traffic on port 22 only from an administrator's IP address
One important characteristic of Security Groups is that they are **stateful**.
This means that if incoming traffic is allowed, the response traffic is automatically allowed.
For example:
A user connects to an EC2 web server through HTTPS on port 443.
If the Security Group allows this connection, the server can automatically send the response back to the user without requiring an additional outbound rule for that specific response.
## What is a Network ACL?
A Network Access Control List, or Network ACL, provides another layer of security for a VPC.
However, unlike Security Groups, Network ACLs operate at the **subnet level**.
This means that the rules apply to resources located inside the associated subnet.
Network ACLs can contain both:
- ALLOW rules
- DENY rules
This is an important difference because Security Groups only support allow rules.
Network ACLs are also **stateless**.
This means that inbound and outbound traffic must be evaluated separately.
If traffic is allowed into a subnet, we must also make sure the appropriate outbound traffic is allowed.
## Security Groups vs. Network ACLs
Here is a simple comparison:
| Feature | Security Group | Network ACL |
|---|---|---|
| Applied to | Resources such as EC2 | Subnets |
| Stateful | Yes | No |
| Allow rules | Yes | Yes |
| Deny rules | No | Yes |
| Inbound and outbound evaluated separately | No | Yes |
## A Simple Example
Imagine a company has an application running on an EC2 instance inside a public subnet.
The Security Group could allow:
- HTTPS (443) from the Internet
- SSH (22) only from the company's administrator IP
Now imagine the company discovers that a specific malicious IP address is repeatedly trying to access the application.
Because Security Groups do not support explicit deny rules, a Network ACL could be used to block traffic from that specific IP address at the subnet level.
In this architecture, both services provide different layers of protection.
## Defense in Depth
One of the concepts I find interesting while learning AWS security is **defense in depth**.
Instead of relying on only one security mechanism, AWS architectures can use multiple security layers.
For example:
Internet → Network ACL → Security Group → EC2 Instance
The Network ACL protects the subnet, while the Security Group controls access to the individual resource.
Using these controls correctly can help reduce the attack surface of an AWS environment.
## What I Learned
The easiest way I found to remember the difference is:
**Security Group = Resource-level firewall**
**Network ACL = Subnet-level firewall**
And another important distinction:
**Security Groups are stateful.**
**Network ACLs are stateless.**
Understanding these concepts has helped me better understand how network security works inside an Amazon VPC.
As I continue my journey toward the AWS Certified Solutions Architect – Associate certification, I plan to keep sharing the AWS concepts I learn along the way.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article