liveBook · Manning

Multi-tier application

As explained in Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

A three-tier application is an application architecture that separates presentation, application, and data responsibilities into distinct tiers.

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

Figure 8.12 Module usage for the three-tier application module

Use the module diagram to follow how reusable Terraform modules compose the complete application. section 8.4

How Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu covers it

How deep it goes
Explains module composition, network placement, routing, security, and environment variation, but does not provide provider-specific resource configurations.
Examples
Uses a CDN, load balancer, API container, database, cache, public and private subnets, NAT, and environment-sized databases.
What it assumes
Assumes Terraform module concepts and introduces how root modules provide variables and provider configuration for composed applications.
What you can do after
Build it from scratch by composing Terraform modules, wiring their inputs and outputs, and placing services across public and private networks.
How it connects
Connects Terraform modules, root modules, load balancers, container services, databases, caches, network segmentation, NAT, and high availability.

Also explained in

Compare how 7 books explain multi-tier application →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu. The section links point to the parts of the book it draws on.