Loading learning content...
In 2017, security researchers discovered that MongoDB databases belonging to thousands of organizations—including healthcare providers and financial institutions—were openly accessible from the internet. The databases contained hundreds of terabytes of sensitive data. These weren't database vulnerabilities; they were network security failures. The databases were simply deployed without proper network isolation, accepting connections from any IP address.
Cloud networking is fundamentally different from traditional networking. There are no physical firewalls to install, no cables to trace, no switches to configure. Instead, cloud providers offer software-defined networking (SDN) constructs: Virtual Private Clouds (VPCs), security groups, network ACLs, and flow logs. Understanding these abstractions is essential for building secure cloud architectures.
Network security complements IAM. While IAM controls WHO can access resources, network security controls WHERE traffic can come from and go to. Together, they create defense in depth.
By the end of this page, you will understand VPC architecture and subnet design, security groups and network ACLs, public versus private network topologies, network traffic flow and inspection, and common network security misconfigurations that lead to breaches.
A Virtual Private Cloud (VPC) is a logically isolated section of the cloud provider's network where you launch resources. Think of it as your own private data center within the cloud—you control the IP address range, subnets, routing tables, and network gateways.
Why VPCs Matter:
VPC Core Components:
VPC Architecture Visual:
┌────────────────────────── VPC (10.0.0.0/16) ──────────────────────────┐
│ │
│ ┌─────────────────── Availability Zone A ───────────────────┐ │
│ │ │ │
│ │ ┌──────────────────┐ ┌──────────────────┐ │ │
│ │ │ Public Subnet │ │ Private Subnet │ │ │
│ │ │ 10.0.1.0/24 │ │ 10.0.3.0/24 │ │ │
│ │ │ │ │ │ │ │
│ │ │ ┌────────────┐ │ │ ┌────────────┐ │ │ │
│ │ │ │ Web Server │ │ │ │ Database │ │ │ │
│ │ │ └────────────┘ │ │ └────────────┘ │ │ │
│ │ │ │ │ │ │ │
│ │ └──────────────────┘ └──────────────────┘ │ │
│ │ │ │ │ │
│ └────────────│───────────────────────│───────────────────────┘ │
│ │ │ │
│ ┌─────────────────── Availability Zone B ───────────────────┐ │
│ │ │ │ │ │
│ │ ┌──────────────────┐ ┌──────────────────┐ │ │
│ │ │ Public Subnet │ │ Private Subnet │ │ │
│ │ │ 10.0.2.0/24 │ │ 10.0.4.0/24 │ │ │
│ │ │ ┌────────────┐ │ │ ┌────────────┐ │ │ │
│ │ │ │ Web Server │ │ │ │ Database │ │ │ │
│ │ │ └────────────┘ │ │ └────────────┘ │ │ │
│ │ └──────────────────┘ └──────────────────┘ │ │
│ │ │ │
│ └────────────────────────────────────────────────────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Internet │ │ NAT │ │
│ │ Gateway │ │ Gateway │ │
│ └─────────────┘ └─────────────┘ │
│ │ │ │
└────────────────│───────────────────────│───────────────────────────────┘
▼ │
Internet ◀──────────────────┘
Key Design Principle:
Public subnets have routes to the Internet Gateway; private subnets do not. Resources in private subnets can access the internet through a NAT Gateway (placed in a public subnet), but the internet cannot initiate connections to them.
Security Groups are stateful, virtual firewalls that control inbound and outbound traffic at the instance (or ENI) level. They're the primary mechanism for controlling network access to cloud resources.
Key Characteristics:
| Direction | Protocol | Port Range | Source/Destination | Purpose |
|---|---|---|---|---|
| Inbound | TCP | 443 | 0.0.0.0/0 | HTTPS from internet |
| Inbound | TCP | 80 | 0.0.0.0/0 | HTTP from internet (redirect to HTTPS) |
| Inbound | TCP | 22 | 10.0.0.0/8 | SSH from internal only |
| Outbound | TCP | 443 | 0.0.0.0/0 | HTTPS to external APIs |
| Outbound | TCP | 5432 | sg-database | PostgreSQL to database SG |
Security Group Best Practices:
Security group rules with source 0.0.0.0/0 mean 'allow from anywhere on the internet.' This is often appropriate for web servers (ports 80/443) but is a critical security failure for SSH, RDP, or database ports. Automated scanners continuously probe for these misconfigurations.
Network Access Control Lists (NACLs) are stateless, optional layer of security that acts as a firewall for controlling traffic in and out of subnets. While security groups operate at the instance level, NACLs operate at the subnet level.
Key Differences from Security Groups:
| Characteristic | Security Groups | Network ACLs |
|---|---|---|
| Level | Instance/ENI | Subnet |
| State | Stateful (return traffic automatic) | Stateless (explicit rules for both directions) |
| Rule type | Allow only | Allow and Deny |
| Rule processing | All rules evaluated | Rules processed in order by number |
| Default | Deny all inbound, allow all outbound | Allow all (default NACL) |
| Association | Multiple SGs per instance | One NACL per subnet |
When to Use NACLs:
NACLs are useful for:
Blocking known malicious IPs — When you need to explicitly deny traffic from specific IP ranges across an entire subnet
Compliance requirements — Some compliance frameworks require explicit subnet-level deny rules
Defense in depth — Adding an additional layer of network control beyond security groups
Emergency response — Quickly blocking traffic at the subnet level during an incident
Example NACL Configuration:
┌────────────────────────────────────────────────────────────────────┐
│ Network ACL: acl-web │
├────────────────────────────────────────────────────────────────────┤
│ INBOUND RULES │
├───────┬──────────┬──────┬───────────────────┬──────────────────────┤
│ Rule# │ Protocol │ Port │ Source │ Allow/Deny │
├───────┼──────────┼──────┼───────────────────┼──────────────────────┤
│ 100 │ TCP │ 443 │ 0.0.0.0/0 │ ALLOW │
│ 110 │ TCP │ 80 │ 0.0.0.0/0 │ ALLOW │
│ 120 │ TCP │ 1024-65535 │ 10.0.0.0/8 │ ALLOW (ephemeral) │
│ 200 │ ALL │ ALL │ 192.168.1.100/32│ DENY (blocked IP) │
│ * │ ALL │ ALL │ 0.0.0.0/0 │ DENY (implicit) │
├───────┴──────────┴──────┴───────────────────┴──────────────────────┤
│ OUTBOUND RULES │
├───────┬──────────┬──────┬───────────────────┬──────────────────────┤
│ 100 │ TCP │ 443 │ 0.0.0.0/0 │ ALLOW │
│ 110 │ TCP │ 1024-65535 │ 0.0.0.0/0 │ ALLOW (ephemeral) │
│ * │ ALL │ ALL │ 0.0.0.0/0 │ DENY │
└───────┴──────────┴──────┴───────────────────┴──────────────────────┘
Important NACL Considerations:
In most cases, security groups are sufficient and easier to manage. Use NACLs as an additional defense layer, not as a replacement for properly configured security groups. The stateless nature of NACLs makes them more error-prone.
A fundamental cloud network security decision is determining which resources need public internet access (and thus exposure to internet-based attacks) versus which should remain private. The general principle: expose only what must be exposed.
Tiered Architecture Pattern:
Most secure architectures follow a tiered model where only a thin edge layer is publicly accessible:
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ INTERNET │
│ │
└────────────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ PUBLIC SUBNET (DMZ) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ ALB │ │ CDN │ │ WAF │ │
│ │ (Public) │ │ Origin │ │ Endpoint │ │
│ └──────┬──────┘ └──────┬──────┘ └─────────────┘ │
│ │ │ │
└──────────│──────────────────│───────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────────────┐
│ PRIVATE SUBNET (Application) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Web App │ │ API Svc │ │ Worker │ │
│ │ Instances │ │ Containers │ │ Queue │ │
│ └──────┬──────┘ └──────┬──────┘ └─────────────┘ │
│ │ │ │
└──────────│──────────────────│───────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────────────────────────┐
│ PRIVATE SUBNET (Data) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Primary │ │ Replica │ │ Cache │ │
│ │ Database │ │ Database │ │ Cluster │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
Zero-Trust Considerations:
Modern network security increasingly follows zero-trust principles—the idea that we shouldn't trust traffic just because it originates from inside our network perimeter. In cloud architectures:
A private subnet is not inherently secure—it's just not directly reachable from the internet. Compromised instances, misconfigured services, or lateral movement from other compromised systems can still attack private resources. Defense in depth is essential.
Cloud networks rarely exist in isolation. Production architectures require connections to on-premises data centers, other VPCs, partner networks, and cloud services. Each connectivity option has security implications.
VPC-to-VPC Connectivity:
| Option | Use Case | Security Considerations |
|---|---|---|
| VPC Peering | Direct connection between two VPCs | Route tables must be explicitly configured; security groups still apply; non-transitive |
| Transit Gateway | Hub-and-spoke for multiple VPCs | Centralized control; can segment routing domains; shared routing |
| PrivateLink | Expose services to other VPCs/accounts | One-way; consumer initiates; service endpoints are private |
| VPN (Site-to-Site) | Encrypted tunnel over internet | Encrypted but uses public internet; limited bandwidth |
| Direct Connect | Dedicated physical connection | Private; high bandwidth; higher cost; physical setup required |
Hybrid Cloud Networking:
Connecting cloud VPCs to on-premises networks introduces additional complexity:
┌─────────────────────────────────────────────────────────────────────────┐
│ ON-PREMISES DATA CENTER │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Corporate │ │ Customer │ │
│ │ Applications │ │ Gateway │ │
│ └─────────────────┘ └────────┬────────┘ │
│ │ │
└──────────────────────────────────────────────────────│───────────────────┘
│
┌──────────────────────────────────┴───────────────────┐
│ VPN / Direct Connect │
└──────────────────────────────────┬───────────────────┘
│
┌──────────────────────────────────────────────────────│───────────────────┐
│ AWS CLOUD │ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ TRANSIT GATEWAY │ │
│ └───────────┬───────────────────┬───────────────────┬─────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ VPC: Prod │ │ VPC: Dev │ │ VPC: Shared │ │
│ │ 10.1.0.0/16 │ │ 10.2.0.0/16 │ │ 10.3.0.0/16 │ │
│ └───────────────┘ └───────────────┘ └───────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────┘
Security Considerations for Hybrid:
Use VPC endpoints for AWS service access whenever possible. Traffic to S3, DynamoDB, KMS, and other services doesn't need to traverse the internet. This reduces attack surface and can improve latency.
Network security isn't just about blocking bad traffic—it's about visibility into what traffic is flowing. Without monitoring, you can't detect attacks, troubleshoot issues, or verify that security controls are working.
VPC Flow Logs:
VPC Flow Logs capture information about IP traffic going to and from network interfaces in your VPC. They're essential for security monitoring and forensics.
Flow Log Record Format:
┌───────────────────────────────────────────────────────────────────────────┐
│ version account-id interface-id srcaddr dstaddr srcport dstport protocol │
│ packets bytes start end action log-status │
└───────────────────────────────────────────────────────────────────────────┘
Example Record:
2 123456789012 eni-abc123 10.0.1.15 10.0.2.25 443 49152 6 12 3456
1620000000 1620000060 ACCEPT OK
Interpretation:
- Source: 10.0.1.15:443 (internal server)
- Destination: 10.0.2.25:49152 (internal client)
- Protocol: TCP (6)
- 12 packets, 3,456 bytes
- Action: ACCEPT (allowed by security group/NACL)
What Flow Logs Reveal:
| Pattern | Security Implication |
|---|---|
| Rejected traffic to SSH/RDP | Potential reconnaissance/brute force |
| Unexpected outbound connections | Possible malware C&C communication |
| Large data transfers to unknown IPs | Potential data exfiltration |
| Traffic between unexpected instances | Lateral movement |
| Connections to known bad IPs | Active compromise |
Network Firewall Deep Inspection:
For environments requiring deep packet inspection, stateful protocol analysis, or intrusion detection, AWS Network Firewall provides a managed solution:
Internet
│
▼
┌───────────────────────────────────────────────────────────────────┐
│ Network Firewall Endpoint │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ Rule Groups: │ │
│ │ - Stateful rules (5-tuple, domain, Suricata) │ │
│ │ - Stateless rules (packet filtering) │ │
│ │ - Managed threat signatures │ │
│ └─────────────────────────────────────────────────────────────┘ │
└────────────────────────────────────┬──────────────────────────────┘
│
▼
Protected Subnets
Alerting and Response:
Monitoring is only valuable if you act on findings:
VPC Flow Logs generate data that you pay to store and process. At scale, this can be significant. Use sampling, filter to relevant traffic, and set appropriate retention periods. But don't skip flow logs entirely—the visibility is essential for security.
Network security failures in the cloud are almost always configuration errors, not technology failures. Understanding common misconfigurations helps you avoid them and detect them during security reviews.
Detection and Remediation:
| Misconfiguration | Detection Method | Remediation |
|---|---|---|
| Open admin ports | AWS Config Rules, Security Hub | Restrict to known IPs, use bastion |
| Public databases | Config Rules, custom scans | Move to private subnet, use proxy |
| Missing flow logs | AWS Config | Enable flow logs for all VPCs |
| Over-permissive SGs | IAM Access Analyzer, manual audit | Remove unnecessary rules |
| Default VPC in use | AWS Config rule | Migrate to custom VPCs |
| Missing encryption | Security Hub checks | Enable encryption in transit, require TLS |
Automated Remediation:
For high-risk misconfigurations, automate remediation:
EventBridge Rule: "Security group allows 0.0.0.0/0 on SSH"
│
▼
Lambda Function: Remove rule and notify
│
▼
SNS Topic: Alert security team
This pattern ensures dangerous misconfigurations are corrected immediately, not days later when a human reviews alerts.
Studies consistently show that cloud breaches are primarily caused by configuration errors, not zero-day exploits or sophisticated attacks. Focus your security efforts on getting the basics right: least privilege, private by default, continuous monitoring.
Network security is the perimeter that determines what traffic can reach your cloud resources. While IAM controls who is authorized, network controls determine what can physically connect.
What's Next:
With network controls establishing the perimeter, we next explore encryption services—protecting data both at rest and in transit. Even if network controls fail, properly encrypted data remains protected from unauthorized access.
You now understand cloud network security architecture—from VPC design through security groups and NACLs to traffic monitoring. This knowledge enables you to design network topologies that minimize attack surface and provide defense in depth.