With Infrastructure as Code (IaC), every aspect of an organization’s infrastructure is defined and managed through code. This infrastructure deployment and configuration automation makes managing the organizations infrastructure much easier over time. Also, by committing the IaC code that configurations the infrastructure into source control, there are change tracking and other benefits for the organizations infrastructure management process. However, infrastructure deployments can suffer from configuration bloat that makes things much more difficult to maintain over time. This is where the concept of “Convention over Configuration” becomes extremely useful for simplifying the IaC code, creating infrastructure standards, and making the IaC code for large scale infrastructure deployments much easier to maintain.

This article takes a look at what “Convention over Configuration” is, and how it can be applied towards small and large scale Infrastructure as Code (IaC) deployments.

What is “Convention over Configuration”?

“Convention over Configuration” (CoC) is a design paradigm that prioritizes sensible defaults and standardized conventions over explicit configuration. This means that a framework or tool will make assumptions about the best way to accomplish tasks, reducing the need for developers to specify every detail explicitly.

At its core, the main goal of CoC is to minimize the amount of configuration required, allowing developers to focus more on writing application logic rather than spending time configuring settings. Developers can achieve faster development cycles by establishing conventions and standards to be followed.

Advantages of Conventions over Configuration

Here are several benefits offered when adopting “Convention over Configuration”:

  • Less code – Following “Convention over Configuration” leads to fewer lines of code written, resulting in cleaner, more concise code
  • Reduced cognitive load – Developers can focus on writing application code without the need to spend time on configuration details
  • Consistency – Following standard conventions across a large project, or even multiple projects, allows for more readable and maintainable code to be written
  • Faster development – By following standards by default, developers can build applications more quickly, helping to shorten the time to get projects deployed into production
  • Improved maintainability – With fewer configuration files and standardized practices, maintaining and updating infrastructure becomes more straightforward and less error-prone.

Origins of Convention over Configuration

The origins of the “Convention over Configuration” concept can be traced back to the Ruby on Rails software development framework in the early 2000s. The creator of Ruby on Rails, David Heinemeier Hansson, introduced this principle as a fundamental philosophy of the Ruby on Rails framework.

Ruby on Rails embraced the idea that developers should follow a set of conventions, such as naming conventions for files and folders, database table names, and routing paths. These conventions allowed developers to build web applications more rapidly without needing to specify eery configuration detail explicitly. It also enabled new project templates to be created using pre-built scaffolding that already had the primary Ruby on Rails conventions in place by default.

The success of Ruby on Rails, and it’s adoption of “Convention over Configuration”, spread interest in this new philosophy across the entire software development community. Other frameworks and languages began to incorporate similar principles, recognizing the benefits of reducing boilerplate code and simplifying development workflows through established conventions.

Here are some examples of Convention over Configuration being used within software development:

  • Ruby on Rails – Rails uses conventions for database table names, routing, and file organization, reducing the need for explicit configurations.
  • Spring Boot – In Java, Spring Boot provides defaults for dependency injection, configuration, and application structure.
  • Django – The Django web framework for Python enforces conventions for project layout, database models, and url routing.
  • ASP.NET MVC – ASP.NET MVC uses conventions for naming conventions, folder structure, routing, default behaviors like model binding, and more.

Convention over Configuration Benefits for IaC

The concepts of “Convention over Configuration” (CoC) can be applied to any area of software development. This includes offering Infrastructure as Code (IaC) the benefits of simplifying management and deployment of infrastructure resources, as well as easier maintenance of both small and large IaC deployment projects.

For developers that have moved over to the infrastructure side of things in a DevOps Engineer or Site Reliability Engineer role, these benefits may more apparent. However, for someone with an IT Pro background moving into these roles, the entire concept of “Convention over Configuration” may by unknown. The DevOps and SRE roles are a bridge between the gap of the development and traditional infrastructure (aka operations) roles, and the development of IaC will benefit from a variety of software development philosophies and methodologies like “Convention over Configuration” that have been used in the industry for a long time already. After all, IaC is code too.

Let’s take a look at the benefits that “Convention over Configuration” offers Infrastructure as Code (IaC) projects of all sizes:

Standardization and Consistency

In IaC, infrastructure components such as servers, networks, and storage resources are defined and managed through code. By adopting CoC, development teams can establish standardized conventions for defining these resources. For example, consistent naming conventions for resources and configuration files can promote clarity and maintainability across infrastructure codebases. This consistency reduces the risk of errors and facilitates collaboration among team members.

Reduced Configuration Complexity

IaC frameworks such as HashiCorp Terraform and Azure Bicep offer powerful capabilities for defining infrastructure configurations. However, configuring these tools to work seamlessly with different environments and setups can become complicated. CoC simplifies this process by providing sensible defaults and predefined conventions. DevOps Engineers and SREs can leverage these defaults to streamline the configuration of infrastructure components, minimizing the need for extensive customization and reducing the potential for misconfigurations.

Accelerated Development Cycles

By embracing CoC, IaC workflows can become more agile and efficient. DevOps Engineers and SREs can focus on writing infrastructure code that adheres to established conventions, rather than spending excessive time on manual configuration tasks. This streamlined approach accelerates development cycles, enabling teams to iterate rapidly and deliver infrastructure changes more quickly. Additionally, the reduced cognitive load associated with CoC allows DevOps Engineers and SREs to maintain their focus on implementing infrastructure requirements, leading to faster time-to-market for applications and services.

Improved Documentation and Onboarding

Clear and consistent conventions serve as a form of self-documentation within IaC codebases. When new team members join a project, they can quickly grasp the structure and organization of infrastructure code, thanks to CoC principles. This simplifies the onboarding process and reduces the learning curve for understanding complex infrastructure configurations.

Enhanced Collaboration and Code Reusability

CoC fosters collaboration by establishing common ground for DevOps Engineers and SREs working on IaC projects. With standardized conventions in place, team members can easily share and reuse code snippets, modules, and configurations across different projects and environments. This promotes code consistency and reusability, ultimately leading to more maintainable and scalable infrastructure solutions.

IaC Modules: IaC tools like HashiCorp Terraform and Azure Bicep support the development of reusable modules. These can be leveraged to help increase code reuse, make the code more DRY (Don’t Repeat Yourself), and have modules adhere to conventions by default. Check out the following articles to read more about developing IaC modules:

Improved Security

Infrastructure security is an area of IaC that every team and organization will be required to define some kind of standards to follow. With CoC the established security standards can be integrated by default and followed by convention within IaC projects. This will make it easier for DevOps Engineers and SREs to follow the established conventions resulting in more secure infrastructure deployments. Also, by combining the security standards in reusable modules when using HashiCorp Terraform and Azure Bicep, the configuration of security standards becomes easy to configure, or even update over time. If the security standard needs to be configured, or updated, then the reusable module can be updated and an infrastructure deployment configured using that module will automatically get the new security standard configuration on the next IaC deployment to the infrastructure environment. This makes it easier to ensure networks, virtual machines, or other infrastructure is secured correctly, as per set security standards, because it’s being done by convention within the IaC project.

Conclusion

“Convention over Configuration” (CoC) offers significant advantages for Infrastructure as Code (IaC) projects by promoting standardization, reducing complexity, accelerating development cycles, improving documentation, and enhancing collaboration. By embracing CoC principles, DevOps and SRE teams can unlock the full potential of IaC to efficiently manage and deploy infrastructure resources with lower maintenance costs.

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
Microsoft MVP HashiCorp Ambassador

Discover more from Build5Nines

Subscribe now to keep reading and get access to the full archive.

Continue reading