A company is designing a multi-tier web application on AWS. The web tier must be accessible from the internet, but the application and database tiers must be isolated. The security team requires that all traffic between tiers be encrypted and that the application tier can only be accessed by the web tier. Which architecture should be used?
Trap 1: Place all tiers in public subnets and use security groups to…
Placing all tiers in public subnets with internet gateways means every instance—including application and database servers—receives a public IP and a direct route to the internet, defeating network isolation. Security groups act as stateful firewalls, but they are not a substitute for subnet-level privacy; any misconfigured rule or application vulnerability can expose sensitive layers. Defense in depth requires limiting internet reachability to only the web tier while keeping app and data tiers in private subnets.
Trap 2: Place the web and app tiers in public subnets and the database in a…
Putting both web and application tiers in public subnets is wrong because the app tier does not need to be publicly reachable and should be shielded from direct internet traffic. An internet gateway attached to the app tier's subnet exposes application logic, APIs, and any underlying services to the internet, greatly increasing the attack surface. The correct pattern is to keep the app tier in a private subnet with a security group that only allows inbound traffic from the web tier, and reserve public subnets for the web-facing load balancer or web servers.
Trap 3: Place all tiers in private subnets and use a single security group…
If all tiers—including the web tier—are placed in private subnets, there is no internet gateway, so the web tier cannot receive inbound user requests from the internet, breaking the application's accessibility. Additionally, using a single security group for all instances allows broad, unfiltered traffic between every tier, violating the principle of least privilege and enabling lateral movement if one tier is compromised. Each tier should have its own security group with narrowly scoped rules, and only the web tier should reside in a public subnet with an internet gateway.
- A
Place all tiers in public subnets and use security groups to restrict traffic.
Why wrong: Placing all tiers in public subnets with internet gateways means every instance—including application and database servers—receives a public IP and a direct route to the internet, defeating network isolation. Security groups act as stateful firewalls, but they are not a substitute for subnet-level privacy; any misconfigured rule or application vulnerability can expose sensitive layers. Defense in depth requires limiting internet reachability to only the web tier while keeping app and data tiers in private subnets.
- B
Place the web tier in a public subnet with an internet gateway, and the app and database tiers in private subnets. Use separate security groups for each tier, allowing only necessary traffic.
This design correctly places the web tier in a public subnet with an internet gateway so it can serve user traffic, while app and database tiers reside in private subnets that have no direct internet route, preventing external access. Separate security groups per tier implement least privilege: the web SG allows HTTP/HTTPS from the internet, the app SG allows traffic only from the web SG, and the database SG permits only the app SG to connect on the database port. This layered isolation still allows end-to-end encryption, for example TLS termination at the web tier and encrypted connections to the application and database layers.
- C
Place the web and app tiers in public subnets and the database in a private subnet.
Why wrong: Putting both web and application tiers in public subnets is wrong because the app tier does not need to be publicly reachable and should be shielded from direct internet traffic. An internet gateway attached to the app tier's subnet exposes application logic, APIs, and any underlying services to the internet, greatly increasing the attack surface. The correct pattern is to keep the app tier in a private subnet with a security group that only allows inbound traffic from the web tier, and reserve public subnets for the web-facing load balancer or web servers.
- D
Place all tiers in private subnets and use a single security group to allow traffic between them.
Why wrong: If all tiers—including the web tier—are placed in private subnets, there is no internet gateway, so the web tier cannot receive inbound user requests from the internet, breaking the application's accessibility. Additionally, using a single security group for all instances allows broad, unfiltered traffic between every tier, violating the principle of least privilege and enabling lateral movement if one tier is compromised. Each tier should have its own security group with narrowly scoped rules, and only the web tier should reside in a public subnet with an internet gateway.