Chapter 10. Designing Infrastructure Code Libraries
As described in Chapter 6, most stack infrastructure tools support code libraries. Terraform, OpenTofu, 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 across projects and to share it between teams. As I’ve touched on before, with Terraform (and OpenTofu) modules are used widely because it’s the only component that the tool supports for 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
A Facade Module creates a simplified interface to a resource from the stack tool language ...
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.