Infrastructure As Code and it's Relevance


Infrastructure as Code (IaC) provisions infrastructure
through code instead of handling with manual efforts.
IaC results into configuration files
which contains infrastructure specifications.

Every DevOps Engineer’s nightmare is undocumented, ad-hoc configuration changes.

In the times of containerization, it is very essentials that same environment is provisioned every time.

Codifying configuration specifications ensures that latest versions are delivered in every build. Having infrastructure as code also means that infra is divided in meaningful reusable components. How about having common Kubernetes cluster specifications with all common stack preloaded?

Provisioning infra with IaC relieves developers from manually provisioning servers, storage, and other infrastructure components. There’s a great set of tool set is available to accomplish the IaC. Tool set can be used to know desired state of infrastructure, which then can be provisioned. It can be used for configuration management to maintain systems in the desired state. Widely used tooling to implement IaC are

Terraform

Chef

Puppet

Ansible

IaC can be achieved with different ways.

Declarative approach maintains the desired state of the system, including resources required. Here list of the current state of system objects is maintained. This makes infrastructure simpler to manage.

An Imperative approach defines the commands needed to achieve the desired configuration. These commands are also required to be executed in the correct order.

Which one is better ?  Majority IaC tools will automatically provision the desired infrastructure. This is declarative approach. If changes are made to the desired state, IaC tool will apply those changes. Whereas an imperative tool will require strategy to identify how those changes should be applied.

Benefits – With advancement in cloud computing, the number of infrastructure components has increased significantly. Agile practices & quest of being early in market results in delivery of frequent builds to production daily. Manually it becomes difficult to manage the multiple components and multi and hybrid cloud scenarios.