Hashicorp's Terraform is a powerful tool for describing as code a set of infrastructure and then safely creating and making changes to that infrastructure over time.

The key benefit of Terraform is that it is able to describe relationships between objects across many different systems and levels of abstraction, using the result of creating one object to define the configuration for another. As well as reducing maintenence burden as things change, this also helps human maintainers to understand how objects relate to one another, helping to turn a sea of infrastructure spread across many systems into a well-understood, version-controlled dependency graph.

Terraform's Getting Started guide covers basic usage of Terraform, including how to describe a simple set of resources in a single configuration and create, update and destroy those resources. This article describes a more complex use of Terraform for managing a large system consisting of several different applications that use a mixture of shared and dedicated infrastructure, deployed in two or more separate environments that allow for changes to be staged before they are released to production.

Due to the two major components involved, I call this (unimaginitively!) the Environment+Application Pattern, or the E+A Pattern for short.

  1. Part 1: Overview and Definitions
  2. Part 2: Creating Environments
  3. Part 3: Per-application Configuration
  4. Part 4: The "Join Environment" Module
  5. Part 5: Conclusion
  6. Part 6: Bonus Patterns