Defining the project structure
In this chapter, we will introduce the usage of Terraform modules to help define and organize our Infrastructure-as-Code (IaC) project structure. Modules allow us to encapsulate and reuse sets of resources to make our Terraform code more modular, maintainable, and scalable. By leveraging modules, we will be able to simplify the management of complex infrastructure deployments and abstract common configurations into reusable components.
In Chapter 3, Succeeding with Infrastructure as Code Tools and Strategies, we stored all our .tf
files in a single directory. It feels a bit messy, right? In case you are wondering how modules change how we organize our code and our files, here’s an example of what the project structure might look like once we utilize Terraform modules:
Figure 4.9 – Sample file and folder structure using Terraform modules
We have in Figure 4.9 a sample file and folder structure (left) along...