Security · AWS SERVICE CHEATSHEET

Security Group (SG)

Attaches directly to EC2 instances, Application Load Balancers, RDS databases, Lambda VPC interfaces, and VPC endpoints. Evaluates all rules before traffic reaches the operating system. Because it is stateful, return traffic is automatically allowed regardless of outbound rules. Supports least-privilege security group ID reference chaining.

Open Interactive SG Sandbox → Simulate in Architecture Studio

AWS Container Placement

VPC

Summary

Stateful virtual firewall controlling inbound and outbound traffic at the Elastic Network Interface (ENI) level.

When to Use (SAA-C03)

Use SG-to-SG chaining (e.g., RDS SG allows port 5432 from App SG ID) instead of broad VPC CIDRs; remember SGs cannot have explicit Deny rules.

Allowed Ingress Connections & Ports

Source ServiceProtocolPortArchitectural Rationale
WEBCLIENTHTTP, HTTPS80, 443Public web browsers and API consumers accessing entry points
ALBHTTP, HTTPS, TCP80, 443, 8080, 3000Load balancers forwarding traffic to backend compute targets
EC2TCP, UDP, ICMPAny port (e.g. 5432, 6379, 3306)Chained instance-to-instance or tier-to-tier microsegmentation
LAMBDATCPAny portVPC-attached Lambda functions invoking internal databases or services

Allowed Egress Targets & Ports

Target ServiceProtocolPortData Flow Rationale
EC2TCP, UDPAny portInternal application routing between microservice tiers
RDSTCP5432 (Postgres), 3306 (MySQL), 1433 (MSSQL)Direct transactional database queries
ELASTICACHETCP6379 (Redis), 11211 (Memcached)Low-latency in-memory cache clustering
INTERFACE-ENDPOINTHTTPS443PrivateLink connections to AWS APIs (SSM, KMS, SQS, S3)

Key Configuration Parameters & AWS Best Practices

ParameterFormat / ExamplePurpose & Rationale
Security Group Name (name) (Required)sg-app-backend-prodUnique name identifier for the Security Group within the AWS account and VPC. Why: AWS requires a name for every security group resource created in EC2-VPC.
VPC ID (vpcId) (Required)vpc-0a1b2c3d4e5f67890Identifies the VPC boundary that contains this Security Group. Why: Security Groups are strictly bound to a single VPC; rules cannot reference SGs across un-peered VPCs.
Inbound Rules (inboundRules) (Required)TCP 443 from 0.0.0.0/0 or sg-albWhitelist specifying permitted ingress traffic protocols, port ranges, and authorized sources (CIDRs, Prefix Lists, or other SG IDs). Why: Default posture of a Security Group is to block ALL inbound traffic until explicitly permitted.
Outbound Rules (outboundRules) (Required)All traffic to 0.0.0.0/0 (Default) or TCP 5432 to sg-dbWhitelist specifying permitted egress traffic protocols, ports, and destinations. Why: Controls outbound traffic initiated by the instance. AWS creates a default allow-all outbound rule, but hardened workloads lock it down.
Description (description)Controls ingress to backend API containers from public ALBHuman-readable documentation describing the purpose and security posture of this group. Why: Assists security auditing, Well-Architected reviews, and compliance tracking.
Revoke Rules on Delete (revoke_rules_on_delete)trueInstructs Terraform to revoke all attached security group rules before deleting the group. Why: Prevents DependencyViolation errors during terraform destroy cycles when circular SG references exist.
Tags (tags)Environment: Production, ManagedBy: TerraformMetadata tags for cost allocation, environment scoping, and infrastructure automation. Why: Enables enterprise resource management and automated compliance scans.

Practice Labs Using Security Group

CLF-02

Locked-Out Security Group Ingress

Add an inbound rule allowing TCP port 80 from 0.0.0.0/0 to the web instance Security Group.…

CLF-03

Public Database Exposure Vulnerability

Move or configure RDS to be in a private subnet, disable public accessibility, and restrict ingress exclusivel…

SAA-05

SaaS Multi-Tenant DB: Least-Privilege Security Group Chaining

Replace CIDR 10.0.0.0/16 with the Application Security Group ID (sg-app) as the authorized source on port 5432…

SAA-08

Multi-Tier Highly Available Web Architecture: Dual-AZ ALB, ASG Fleet & Multi-AZ RDS

Re-architect for multi-AZ high availability: map the public ALB across dual AZs (us-east-1a and us-east-1b), d…

SAA-12

Publish Private Compute: Secure Route 53 CNAME & Dual-AZ ALB Reverse Proxy

Expose the private EC2 compute service via an Internet-Facing ALB spanning two public AZs, configure Target Gr…

SAA-13

FinTech SaaS Link: PrivateLink Interface Endpoint Security Group Block

Add an inbound rule to sg-vpce allowing TCP port 443 from sg-app.…

Frequently Asked Questions

Where does Security Group live inside an AWS VPC architecture?

Valid container placement: VPC. Attaches directly to EC2 instances, Application Load Balancers, RDS databases, Lambda VPC interfaces, and VPC endpoints. Evaluates all rules before traffic reaches the operating system. Because it is stateful, return traffic is automatically allowed regardless of outbound rules. Supports least-privilege security group ID reference chaining.

When should I use Security Group on the AWS SAA-C03 exam?

Use SG-to-SG chaining (e.g., RDS SG allows port 5432 from App SG ID) instead of broad VPC CIDRs; remember SGs cannot have explicit Deny rules.

Can I simulate Security Group packet routing without an AWS account?

Yes. CloudTracer simulates Security Group along with 53 AWS services directly in your browser and exports production Terraform HCL.

More Security Cheatsheets

Network ACL → AWS WAF → IAM Roles & Policies → KMS Encryption Keys → AWS Shield DDoS → Network Firewall →