VPC design
Only the load balancer faces the internet
Public subnets hold the load balancer and NAT gateway; app and data tiers sit in private subnets in two zones.
Here is the standard shape of a secure network in the cloud, across two zones. The public subnets route to the internet gateway. Only the load balancer and the NAT gateways live here. The app servers sit in private subnets. They can reach out through the NAT gateway in their own zone, for updates, but nothing on the internet can reach in. The database sits in a third pair of subnets that accept only the app tier, with a standby in the second zone. And the network is only one layer. An attacker also has to pass the edge, the security groups, identity, and encryption. Each layer assumes the one in front of it might fail.
NAT gateways and VPC endpoints · Going deeper
Reach AWS services through endpoints, not the NAT gateway
Gateway endpoints for S3 and DynamoDB are free; the same 10,000 GB through NAT costs $450 a month.
Security groups
Each tier accepts traffic only from the tier in front of it
A security group is a stateful allow-list on each interface, and a rule can name another group instead of addresses.
Security groups turn that layout into rules. The load balancer’s group accepts HTTPS from anywhere. The app servers’ group accepts port 8080, but only from members of the load balancer’s group. The database’s group accepts its port only from the app group. So any other server, even one inside the same network, is refused. Because rules name groups rather than addresses, servers can scale in and out and the rules still hold.
Network ACLs · Going deeper
Security groups and network ACLs compared
Network ACLs are stateless subnet rules that can deny; security groups are stateful and allow only.
Encryption and keys
Encrypt data with a data key, and the data key with KMS
Envelope encryption: data is encrypted locally with a data key; a KMS key that never leaves KMS encrypts that key.
Encryption is easy. Managing the keys is the hard part. The application asks KMS for a data key, and gets it twice: once in plain form and once encrypted under a KMS key that never leaves KMS. It encrypts the data with the plain key, throws that key away, and stores the encrypted data next to the encrypted key. To read it back, it sends the encrypted key to KMS, which decrypts it only if IAM and the key policy allow, and logs the request. So access to data becomes permission to use one key. S3, EBS and RDS do exactly this when encryption is switched on.
Secrets Manager · Going deeper
Keep secrets out of code, and let them rotate
Secrets Manager hands secrets to IAM roles at run time and rotates them on a schedule.
IAM and least privilege
Everything is denied unless a policy allows it
An explicit Deny wins; an SCP caps the account; a role or resource policy must allow. Use IAM roles with least privilege.
Every call to AWS is checked the same way. Take an app role asking to read a file from a bucket. First, is there an explicit deny anywhere? If so, it is refused, whatever else says. Next, does the organisation’s service control policy allow this action in this account? These policies set the ceiling for whole accounts, even for administrators. Then, does the role’s policy, or the bucket’s, allow it? If nothing does, the answer is no by default. Only then is it allowed. Give workloads roles, which hand out short-lived credentials, and grant only the actions and resources the job needs.
WAF and Shield · Going deeper
Stop attacks at the edge, before they reach your servers
Shield Standard absorbs network floods for everyone; AWS WAF blocks exploits and rate-limits each address.
Hybrid and multi-VPC networking
Connect many networks through a hub, not a mesh
Peering 50 VPCs needs 1,225 links; a Transit Gateway needs 50 attachments. VPN starts fast; Direct Connect is a private line.
Real organisations have many networks. Peering joins two VPCs directly, and it does not pass traffic on, so connecting every pair of six needs fifteen links. For fifty, it is 1,225. A Transit Gateway is a hub: each network attaches once, and routing is managed in one place. To reach your own data centre, a site-to-site VPN runs encrypted tunnels over the internet and is ready in minutes. Direct Connect is a private line with steady latency and much more bandwidth, but it takes weeks to install. Many designs use both, with the VPN as the backup.
Lesson complete
You finished “Security and network design”
Nicely done.