Chapter 10. Infrastructure Code Libraries

Most stack infrastructure tools support code libraries. Terraform, CloudFormation, and Bicep call them modules, CDK has Constructs, and Pulumi has Component Resources. Organizing code into a library makes it possible to reuse the code between projects and higher-level components and to share it between teams. As I’ve mentioned before, Terraform modules in particular are widely used because they are the only component type for which the toolchain supports versioning, distributing, and sharing code. This is why Terraform modules are often adapted into deployment components, as described in “Pattern: Stack Module” and “Pattern: Deployment Wrapper Stack”.

In this chapter I’ll describe some common patterns and antipatterns for designing and implementing code libraries.

Pattern: Facade Module

Also known as: wrapper module.

A facade module creates a simplified interface to a resource from the ...

Get Infrastructure as Code, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.