Managing servers and infrastructures manually is not a very complicated task, but when you start working with multiple servers, manual configuration is getting more complex and almost unachievable. This is where the notion of Infrastructure as a Code comes in.
What is IaC?
Infrastructure as a Code is also known as Configuration Management and is an approach that allows management and configuration of physical and virtual machines programmatically. This way, we can define and control the configuration of all servers from one place.
Pros of using IaC
The advantages of using such approach are, among others:
no room for manual tasks - configuration of servers is done through a management tool that implements the changes for us whenever we need it
no dependency on others - usually, any server changes are performed by the IT department since they require admin access. By using IaC it is possible to make changes on our own while the tools will ensure that the changes we make are properly applied to the servers and to our infrastructure
automation - systems are built, managed and provisioned automatically through the code and the updates are made through changes in the code
the infrastructure becomes: consistent, testable, maintainable, reusable and extensible
fewer errors - manual updates can cause problems since they are prone to human error
the code is also the documentation - there is no need to prepare separate documents with the documentation since all the necessary information is in the code
source control - we acquire a central place where everybody can put their code, which allows versioning
faster delivery - thanks to the reusability and flexibility
Popular IaC tools
There are many tools that can be used to automate the deployments, the most popular being:
Terraform - allows creating execution plans outlining what will happen when the code will be run, uses own domain-specific language Hashicorp Configuration Language that is JSON-compatible
Pulumi - helps to define cloud apps and infrastructure in any language and deploy to any cloud
Ansible - the tool describes how the system and the components relate to each other instead of managing systems independently
Chef - uses Ruby-based DSL, follows a procedural approach to configuration management where it is necessary to describe the procedures that will result in getting to the desired state
Puppet - the tool enforces the desired state automatically and fixes incorrect changes, the state of the infrastructure and what is expected of it to do have to be defined
Docker - helps to create containers that pack the dependencies and the code together, therefore allowing the application to run in any environment
Saltstack - takes an ‘infrastructure as data’ approach, its declarative configuration patterns are written in Python and are language-agnostic
AWS CloudFormation - allows coding the infrastructure in order to automate the deployments, it can only be used with AWS
Infrastructure as a Code is a beneficial approach that will help you manage servers and infrastructures more efficiently and most importantly, automatically. This means, you will experience fewer errors, will deliver faster and gain independence from the IT people. The code you write will become your documentation so you can dedicate the time saved to some other issues.