Back to posts
Jan 10, 2026
4 min read

AWS Security Group: The Dedicated “Gatekeeper” at the Instance Level

On the journey to conquering the AWS Certified Solutions Architect Associate (SAA) certification, Security Group (SG) is one of the most important concepts. If you think of VPC as a building and Subnets as floors, then Security Group is the security layer right at the door of each apartment (EC2 Instance).

This article will dive deep into how it works, its critical characteristics, and why the “SG Reference” feature is a game-changer in cloud infrastructure management.

1. What is a Security Group?

Essentially, a Security Group is a virtual firewall that operates at the Instance level. It controls network traffic (Inbound and Outbound) for AWS resources, most commonly EC2 servers.

Core Operating Principles:


2. 5 “Golden” Characteristics of Security Groups

To pass the SAA exam and operate effectively in practice, you need to know these characteristics by heart:

  1. Operates at Instance Level: SGs are attached directly to the network card (ENI) of the instance, not at the Subnet level. This provides maximum flexibility for each individual server.
  2. Stateful: This is the most important characteristic. If you allow a request to come in (Inbound), the system will automatically open the path for the response to go out without needing to check the Outbound rules, and vice versa.
  3. Allow Only, No Deny: You cannot write a rule to “block a specific IP.” You can only “allow what is trusted,” and everything else is blocked by default.
  4. Immediate Effect: All rule changes take effect immediately without requiring a server reboot.
  5. Many-to-Many Relationship: One SG can be assigned to multiple Instances, and one Instance can have up to 5 SGs. In this case, the rules are aggregated to determine access permissions.

3. Distinguishing SG from Network ACL (NACL)

Many people confuse these two concepts. Remember this quick comparison table:

FeatureSecurity Group (SG)Network ACL (NACL)
LevelInstance LevelSubnet Level
StateStateful (Auto-opens return path)Stateless (Must open both directions)
RulesAllow onlyAllow and Deny
Priority OrderAll rules aggregatedEvaluated by rule number (low to high)

[Image comparing Security Group at instance level vs Network ACL at subnet level]


4. The Art of Troubleshooting: Timeout or Connection Refused?

SGs act as a Wrapper around the Instance. This leads to two classic error scenarios that you need to distinguish:


5. Security Group Reference: The “Weapon” for Auto Scaling

Instead of filtering traffic based on IP addresses (which change frequently in the Cloud), AWS allows you to filter based on the Identity of another Security Group.

Why is it “Awesome”?

Imagine your system has dozens of Web Servers in an Auto Scaling group. These IPs will change constantly as new servers spin up or get terminated.

Practical Example:

  1. Instance A (Database) has SG-DB attached.
  2. You configure the Inbound rule for SG-DB: allow Port 3306 with Source as SG-Web-ID.
  3. Any machine (Instance B, C, D…) that has SG-Web attached will automatically be able to connect to the Database regardless of its IP.
  4. Self-reference: If you set the Source of an SG to itself, all machines in the same group can freely communicate internally (commonly used for clusters like Kafka, ElasticSearch).

Conclusion

Security Group is not just a simple security tool — it represents role-based access management thinking on network infrastructure. Understanding SGs thoroughly will help you design systems that are both highly secure and strongly scalable.

Related