Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Infrastructure as Code (IaC) is the practice of configuring, provisioning, and managing infrastructure resources using code. It is an integral component of DevOps methodology, facilitating the seamless orchestration of applications and their underlying infrastructure such as servers, virtual machines, databases, and networks.

Project Structure and Organization

When handling projects, it's important to establish a well-organized directory structure to effectively manage your project and potential complexities. It's recommended to maintain distinct directories for various purposes and ensure a uniform format, style, and code structure.

Directory Structure

The recommended directory structure for any IaC project includes separating code, configuration, and documentation into organized folders. By following an organized directory structure, you make it easier for team members to locate and manage specific elements of your IaC project, maintain consistency, and collaborate effectively. It also facilitates version control and ensures that your project remains clear, maintainable, and scalable.

Note: An IaC project typically undergoes multiple iterations to align with a company's specific project requirements, and its initial definition may not be entirely accurate.

  • Root Directory: The root directory of your IaC project typically contains high-level configuration files and important project-wide documentation. It may include files like "main.tf" (for Terraform) or "site.yml" (for Ansible) as the entry point for your IaC code.

  • Code Directory: This is where you store the actual IaC code. You should create subdirectories for different components or environments.

For example, you may have subdirectories like "networking," "servers," or "dev," "staging," and "production" if you're managing different environments.

  • Configuration Directory: This directory is meant for configuration files that are separate from the IaC code. These can include environment-specific configurations, application settings, or any other data that needs to be kept separate from the code logic.

Store configuration files that are separate from your IaC code in this directory.

  • Documentation Directory: It's a good practice to have a dedicated folder for documentation. This directory should contain files explaining the project's purpose, architecture, and usage, along with any user or developer guides.

  • Modules/Scripts Directory: If your IaC project is sufficiently complex, you may want to have a directory specifically for reusable modules, scripts, or functions. These can be shared and included in your code as needed.

  • Variables Directory: Store variable definitions in a dedicated directory. This can help keep variables separate from the code logic and make it easier to manage and change configurations.

  • Tests Directory: If your IaC project includes automated tests (highly recommended), place your test files or scripts in this directory. This helps ensure code reliability.

  • Infrastructure State Directory: Some IaC tools maintain state files that track the current state of deployed resources. Keep these files in a separate directory to prevent accidental modifications.

  • Secrets Directory (Optional): For security and separation of concerns, you may consider having a separate directory for managing secrets and sensitive data. Ensure strict access controls on this folder.

  • Logs and Reports Directory (Optional): If your IaC project generates logs or reports, you can have a directory for storing these files.

  • Bin or Scripts Directory (Optional): If you have utility scripts or binaries that assist in the IaC process, place them in this directory.

Naming Conventions

Repository Layout


Infrastructure Provisioning

Possible Sub-pages/topics:

  • Explanation of IaC Language (Terraform and Ansible terminologies)

  • Creating Infrastructure Resources

  • Resource Dependencies and Order(?)


Configuration Management

Possible Sub-pages/topics:

  • Managing Configuration Files

  • Secrets Management

  • Parameterization and Variables

Setting Up IaC Environment

Possible Sub-pages/topics:

  • Pre-requisite Requirements

  • Installation and Configuration

  • Environment Variables

  • No labels