Notes
VPCs and subnets
The foundation is a VPC, your own isolated virtual network. You split it into subnets: public versus private. A public subnet can reach the internet and is where internet-facing things live, mainly load balancers. A private subnet has no direct internet path, and that is where your applications and databases belong. The goal is that almost everything lives private, and only a thin, deliberate layer is exposed. Most exposed-service breaches are something private placed where it should not be.
- VPC: your isolated virtual network in the cloud
- public subnet: can reach the internet (load balancers, gateways)
- private subnet: no direct internet path (apps, databases)
- the goal: almost everything lives private
Security groups
The main control you will use is the security group: a virtual firewall attached to each resource. It is stateful, so if you allow a request in, the reply is allowed out automatically. It is allow-only: you list what is permitted, and everything else is denied by default. Best practice is to reference other security groups rather than IP addresses, allow from the app group to the database group, so rules follow your architecture instead of brittle address ranges. This is your everyday network tool.
- a virtual firewall on each resource (instance, DB)
- stateful: return traffic is allowed automatically
- allow-only: you list what is permitted, deny is implicit
- reference other groups: "allow from the app group", not IPs
- the main tool you will use daily
Security groups vs NACLs
People often confuse security groups with network ACLs. A security group sits on the resource, is stateful, and is allow-only. A network ACL sits on the subnet, is stateless, meaning you allow both directions, and supports explicit deny as well as allow. ACLs are coarse and act as a backup layer, for example blocking a known-bad IP range across a whole subnet. In practice security groups do most of the work, and ACLs are an occasional, broad-strokes control.
- security group: on the resource, stateful, allow- only network ACL: on the subnet, stateless, allow AND deny
- NACLs are coarse, a backup layer (e.g. block a bad IP range for a whole subnet)
- security groups do most of the work
Private endpoints
A powerful but underused control is private endpoints. By default, when your workload talks to a managed cloud service like storage, that traffic may go out over the internet, even though both ends are in the same cloud. A private endpoint creates a private link from your VPC directly to the service, so traffic never touches the public internet. No public IP, a smaller attack surface, often lower cost. For sensitive flows, private endpoints are the difference between internal and internet-exposed.
- by default, reaching a cloud service (storage, DB) may go over the internet
- private endpoints: a private link from your VPC to the service
- traffic never leaves the cloud backbone
- no public IP, smaller attack surface, often cheaper too
Egress filtering
People lock down inbound traffic but leave outbound wide open. Attackers rely on open egress to send your data out and reach their command-and-control servers. So filter egress too: restrict outbound traffic to known destinations, using an egress proxy or firewall to allowlist where workloads may connect. This stops data exfiltration and limits what a compromised workload can do, since it cannot phone home or reach the internet freely. Outbound control is a quietly powerful defence.
- most rules focus on inbound; outbound is often wide open
- attackers use open egress to exfiltrate data and reach command-and-control servers
- restrict outbound to known destinations
- egress proxy or firewall for allowlisting
- also limits a compromised workload
Private by default
All of this reduces to one rule: private by default. Nothing is reachable from the internet unless there is a clear, deliberate reason. Databases, caches and internal APIs are always private. The only public surface is a load balancer in front of your web tier. No data store ever has a public IP. And because mistakes happen, you continuously scan for anything unexpectedly public, which is what the posture tools in coming episodes do. Private by default prevents the exposed-service breaches from episode two.
- nothing is public unless there is a clear reason
- databases, caches, internal APIs: always private
- expose only via a load balancer or gateway
- no public IPs on data stores
- scan for anything unexpectedly public (CSPM, next episodes)
Common mistakes
Mistakes. A database in a public subnet with a public IP, reachable from anywhere. A security group open to the whole internet on sensitive ports like the database or SSH, which scanners find instantly. Wide-open outbound traffic that lets a compromise exfiltrate freely. Rules written by IP address that drift, instead of referencing security groups. No private endpoints for sensitive flows. And relying on network controls alone while neglecting identity, when you need both.
- a database in a public subnet with a public IP
- security group open to 0.0.0.0/0 on sensitive ports
- wide-open outbound/egress
- rules by IP that drift, not by security group
- no private endpoints for sensitive data flows
- relying on network alone, not identity too
Say it like this
In the interview: I design networks private by default. Applications and databases live in private subnets with no internet path, and only a load balancer is public. I use security groups that reference each other rather than IP addresses, with network ACLs as a coarse subnet-level backup. I use private endpoints so sensitive traffic never crosses the internet, and I filter egress to stop exfiltration and command-and-control callbacks. And I treat network security as defence in depth alongside identity.
- "Private by default: apps and databases in private subnets, only a load balancer public.
- Security groups referencing
- each other, not IPs; NACLs as a coarse backup. Private
- endpoints so sensitive traffic
- avoids the internet, and egress
- filtering to stop exfiltration.
- Defence in depth with IAM."