Infrastructure Design Pattern Catalogue

Introduction to this catalogue

This catalogue describes useful approaches for designing infrastructure which is defined as code, and managed like software. Each pattern in the catalogue describes a recurring and useful solution, giving the context in which it may be useful, and some advice on implementation. (Read the full introduction)

Infrastructure Stack Definition

An Infrastructure Stack is a collection of infrastructure elements that is defined, provisioned, and updated as a unit. The elements of the stack are defined in source code, and may include a combination of compute, networking, and/or storage resources. A stack management tool reads the source code and interacts with an infrastructure platform to ensure the specified resources are provisioned as an instance of the stack. (Read more)

Stack Code Module A Stack Code Module is infrastructure code that can be included into one or more infrastructure stack projects.

Patterns for Replicating Infrastructure

Most organisations need to run multiple copies of infrastructure, whether it’s multiple environments for testing a system, or separate instances of an application for different customers. This pattern catalogue describes the concept of an infrastructure stack as a collection of infrastructure defined and provisioned as a unit - a Terraform project, CloudFormation stack, etc. There are different ways to replicate infrastructure in relation to these stacks. Some of these ways are useful, which are described here as patterns. Other ways are best avoided, which are described as antipatterns. (Read more)

Template Stack Pattern A Template Stack is an infrastructure stack source code project that is used to create multiple instances of the same thing. This is in contrast to singleton stacks, where a separate copy of the source code is maintained for each stack instance, and the many headed stack, where multiple environments are all included in a single stack.
Singleton Stack Antipattern The Singleton Stack antipattern uses a separate copy of the stack source code project for each infrastructure stack instance.
Many-headed Stack Antipattern A Many-Headed Stack manages the infrastructure for multiple environments in a single stack project.

Patterns For Structuring Stacks

A key challenge with infrastructure design is deciding how to size and structure stacks. The infrastructure for a given system may be defined as a single stack, or spread across multiple stacks. Shared code may also be used across stacks. (Read more)

Monolithic Stack Antipattern A Monolithic Stack is an infrastructure stack that includes too many elements, so that it is difficult to work with.
Micro Stack Pattern The Micro Stack pattern involves dividing a system into multiple, loosely coupled infrastructure stacks, so that it is easy to manage them independently.
Single Service Stack Pattern A Single Service Stack defines the infrastructure specific to a single application in its own infrastructure stack.
Multi-Service Stack Pattern A Multi-Service Stack hosts multiple applications in a single instance of the infrastructure stack.
Cross-Stack Service Pattern Defining the infrastructure to host an application across multiple infrastructure stacks is the Cross Stack Service pattern. This is a variation of the micro stack pattern.

Patterns For Configuring Stacks

Defining an infrastructure stack as code enables the creation of multiple instances of the stack. Some aspects of the stack may need to vary for different instances of the stack - at the least, different names, identifiers, and/or tags are needed to distinguish the different instances. There are different techniques for setting configuration for instances of a stack. (Read more)

Command-line Stack Parameters Pattern The simplest way to provide values for a stack instance is to pass the values on the command line.
Stack Instance Script Pattern A separate script, such as a shell script or batch file, can be written to provide the stack management tool with the appropriate values for the each stack instance.
Stack Instance Configuration File Pattern Values can be provided to instances of template stacks by putting them into files, which are then checked into version control.
Wrapper Stack Pattern A Wrapper Stack is an infrastructure stack project which is a thin wrapper to create a specific stack instance, using infrastructure code shared in a stack code module. The purpose of the wrapper is to define the stack parameter values for stack instances managed using template stacks.
Pipeline-Defined Parameters When instances of a template stack is managed using a Continuous Delivery Pipeline, stack instance values can be defined in pipeline job configuration. Each stage which applies the stack code to a given environment includes configuration values for that environment, which is then passed to the command which applies to the code.
Stack Parameter Registry Configuration values for template stacks can be stored in a parameter registry. The appropriate set of values can be retrieved from the registry by the stack management tool or wrapper script when applying the code to a stack instance.