A multi-tier application separates presentation, application, and data responsibilities. A typical three-tier deployment places a load balancer at the presentation edge, an API container in the application tier, and a database and cache in the data tier. section 8.4 section 10.2.2
Terraform commonly models the application with reusable modules for the CDN, load balancer, container service, database, and cache. A higher-level module wires their outputs to other modules’ inputs and exposes environment-specific settings such as database size and network selection. section 8.4
Deploying the tiers requires explicit network and security boundaries:
- Place the load balancer in a public subnet so internet traffic can reach it. section 10.2.2
- Keep the API container, database, and cache in a private subnet because they should not be directly internet-accessible. section 10.2.2
- Route private-network internet access through a NAT service on the public network. section 10.2.2
- Add security groups or firewalls to each service; network segmentation alone is not sufficient protection. section 10.2.2
Environment-specific Terraform deployment
A development deployment can reuse the same composed application module while selecting a smaller database and a different network. The root module supplies those variables and configures the providers, while the composed module creates and connects the application tiers. section 8.4
Figure 8.11 Three-tier web application architecture
Use the architecture diagram to trace presentation, application, and data responsibilities across the deployed services. section 8.4
Use the module diagram to follow how reusable Terraform modules compose the complete application. section 8.4






