How marcinkasprowicz/ultimate-terraform-folder-structure works
Main Components
• Environments: There are multiple environment directories under infrastructure/environments, including “com”, “pre”, “pro”, and “rev”. Each of these holds its own Terraform configuration (main.tf, outputs.tf, variables.tf, etc.), indicating the use of Terraform workspaces for environment segregation.
• Modules: There are two levels of modules. At the top-level “infrastructure/modules”, you have modules like “app”, “db”, and “queue” which encapsulate common infrastructure components. Additionally, within some environment folders (e.g., “com”) you see sub-modules such as “notifier” that are specific to that environment.
• Supporting Tools & Scripts: The repository includes package.json, a small “src” folder with an index.js file, and scripts (like install_terraform.sh). These likely support development, testing, or automation of the deployment process rather than directly being part of the infrastructure code.
• CI/CD & Versioning: Files like .travis.yml and .terraform-version help manage CI/CD and versioning of Terraform, indicating integration with build pipelines and environment management.
b. Module Layer: Illustrate the common modules (app, db, queue) as separate reusable components. Also, include any sub-modules (like the “notifier” module under the “com” environment) and show how these integrate with the environment configurations.
c. Tooling and Scripts: Add a supporting component for the automation and CI/CD tools (Travis CI, tfenv management, and the scripts folder). This component shows how external processes interact with the core Terraform configurations.
Architectural Patterns and Design Principles
• Modular Architecture: Emphasize that the repository follows a modular pattern, significantly reducing duplication by using shared Terraform modules for repeated infrastructure components.
• Environment Isolation: Highlight the segregation of environment-specific configurations through separate folders and the use of Terraform workspaces – an important design principle for separate lifecycle management.
• Infrastructure as Code (IaC): The entire structure is designed to be managed as code, allowing version control (with .gitignore) and continuous integration (via .travis.yml) for robust infrastructure provisioning.
• Reusability and Extensibility: The existence of both environment-specific and globally shared modules suggests a design that prioritizes reusability and ease of extending infrastructure components.
Summary
• Surround these core components with a layer representing CI/CD integration (Travis CI, tfenv) and automation scripts.