liveBook · Manning

Prototype pattern

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

A reusable design pattern that defines static default values or configuration for consumption and extension by other modules.

The prototype pattern builds static defaults from input variables for other modules to consume and extend. It usually exports configuration rather than creating infrastructure resources. A tagging prototype centralizes customer, business-unit, cost-center, and automated metadata so resources receive consistent values. section 3.4

Use the pattern when configuration should be copied consistently across resources:

  • Store shared metadata or other common configuration in one module. section 3.4
  • Reference the exported values from resource modules instead of hardcoding repeated strings. section 3.4
  • Choose it when predictable shared attributes matter more than resource-specific construction; combine it with factory or builder patterns when needed. section 3.6

Standard tags for a server

A StandardTags module returns a copy containing customer, automated, cost-center, and business-unit values. A server configuration consumes those values as labels, allowing common metadata to evolve in one place.

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

How deep it goes
Defines inputs, exported defaults, implementation, rationale, and pattern selection without detailing infrastructure-provider internals.
Examples
Uses shared resource tags, a dictionary analogy, Python modules, and Google infrastructure labels as teaching examples.
What it assumes
Assumes familiarity with infrastructure modules, input variables, resources, and shared configuration.
What you can do after
Build it from scratch by exporting reusable defaults and consuming them from resource modules.
How it connects
Connects to factory, builder, composite, and singleton patterns through modular infrastructure composition.

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.