liveBook · Manning

Module

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

A module is a distinct, bounded software unit that groups related code or functionality and provides an organizational or interaction boundary within a larger system.

An infrastructure module is a separable group of infrastructure resources organized around a function or business domain. It acts as a building block: callers compose modules, customize inputs, and consume controlled outputs without managing every resource directly. section 3.2 section 4.2.1

Use modules to keep related resources together while limiting the blast radius of change. A network module can contain a network and subnet; a load-balancer module can combine a load balancer, domain name, and routing rules. Replacing one module should not require rewriting unrelated infrastructure. section 1.3.3 section 3.2

Build and manage a module by applying these practices:

  • Group resources that share a function or business domain, then expose only the attributes that dependent modules need. section 3.2 section 4.2.1
  • Pass references through inputs and outputs instead of hardcoding identifiers; this loosens dependencies between modules. section 4.0 section 4.2.1
  • Choose a pattern according to uniqueness, reuse, update frequency, and composition; factory and prototype patterns commonly support reusable modules. section 3.6
  • Share opinionated defaults, test formatting and contracts, run integration tests where practical, and govern disruptive releases. section 5.4 section 6.7.1

Network and server modules

A NetworkModule can create a network and subnet and output the subnet name. A ServerFactoryModule reads that output rather than embedding the subnet identifier, then creates a server on the discovered network. The same arrangement lets another resource consume a subnet address range when the network module exposes it. section 3.2 section 4.2.1

Figure 1.9 You build your production environment with building blocks of infrastructure so you can add new resources, like the premium load balancer, easily.

Use the building-block diagram to trace how network, server, and load-balancer modules compose a production environment and how one module can be replaced or extended. section 1.3.3

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Explains module boundaries, patterns, dependencies, testing, sharing, and release governance, with implementation examples but no complete provider-specific deployment.
Examples
Demonstrates network, subnet, server, database, load-balancer, and tags modules through Python, Terraform JSON, state outputs, repositories, and release workflows.
What it assumes
Assumes infrastructure-as-code fundamentals and resource dependencies, while teaching modular boundaries, interfaces, patterns, testing, and collaboration practices.
What you can do after
Builds and shares reusable modules, connects them through outputs, tests changes, and releases governed versions.
How it connects
Connects infrastructure as code with composability, dependency management, design patterns, testing, version control, and continuous delivery.

Also explained in

Compare how 35 books explain module →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.