Infrastructure as Code

  • Post author:
  • Reading time:14 mins read
4.9
(8)

Infrastructure as Code(IaC)

Overview

Infrastructure as Code(IaC) is a tool for provisioning Infrastructure .Provisioning of infrastructure resources were managed manually, this manual process is cumbersome and time consuming. Infrastructure as Code( IaC) helps us to automate the infrastructure provisioning, configuration and managing process . Let’s see why IaC is required and how it solves the problem in managing the Infrastructure.

What is IAC?

Computer Hardware, Software ,OS and Applications has to be configured manually before deploying in to the system.Also as per business needs there are situations where infrastructure are provisioned and de-provisioned based on increase and decrease in workloads . This involves availability of administrators for setting up the server, Virtual machine, Configure load Balancer, network etc to do this Job. To overcome this, Infrastructure as Code (IaC) automates the process by using single or combination of IaC Tools to carry out this Task.

How IaC Works

Configuration Files to Provision the Infrastructure is created using a template. The scripts can be created and used many times across multiple environment. This IaC Code can be version controlled. for example, say for building application on the cloud (or on-premise DC)we need to have VM to host the application, DB , storage  and VPC for connectivity.For having this basic infrastructure in place we need to document it and for moving to test & production again we need to re-create similar environment. To spin new environment again we need to Configure . Here IaC comes in to place in automating the process for quick availability and error free task and also makes identical environment.

IAC approach

Imperative Vs Declarative

Infrastructure as code uses Imperative (Procedural) or declarative approach  to code the  deployment processes.

Imperative approach is a step by step approach. Here each step has to be carried out one after another without  breaking flow . For example Create VM, add storage,  add VPC etc. Over a Period of time when there is a Infrastructure changes then Imperative Code is difficult to adopt the Changes. Scenarios like simple Create, Update and delete infrastructure resources  imperative is used.  

Declarative approach we need to define the end state of the Requirement. In some situation like Scale up and Scale Down we need to write custom code where this approach is used.Declarative IaC adopts configuration Drift. No matter how many times we run the scrip the infrastructure remains the same. Hence Declarative approach is preferred as it has greater flexibility compared to imperative approach. Building Sophisticated Infrastructure needs Declarative style   E.g. Terraform  

Mutable Vs Immutable

Mutable infrastructure is infrastructure that can be modified or updated after provisioning. After Provisioning we can add more server make changes to the Configuration etc.. In mutable Infrastructure we need to track the version

Immutable infrastructure Once Infrastructure Provisioned cannot be modified. If Modification is Required it has to be replaced by building new infrastructure.

For Example say we are planning to Upgrade a Web server. There can be 2 approach in doing this either upgrading the existing Infrastructure(Mutable) or Creating a New Infrastructure (immutable) and delete the Current Infrastructure. Virtualization makes Immutable infrastructure possible to a great extent.

Infrastructure-as-code Tools

There are many IaC Tools for Provisioning, Configuring and Automating the Infrastructure. More than one IaC Tools or Combination of Tools are used to achieve the following Task.

                  * Infrastructure Provisioning
                  * Configuring the infrastructure
                  * Deploying Application on the infrastructure
                  * Managing Infrastructure– reconfigure/ software Updates

 
One single Tool cannot all the purpose so one or more IaC tools used for the above Task ,for Example terraform is used for Provisioning and Ansible used for Installation and deployment. Hence Based on the Preferences and Needs we need to Choose IaC Tools. Examples of infrastructure-as-code tools include AWS CloudFormation, Red Hat Ansible, Chef, Puppet, SaltStack ,Terraform etc…

Popular IaC Tools

Application of IaC

      • Resource Provisioning(Server Build)
      • Database Provisioning
      • Network Configuration
      • User Account Management
      • Scale up/ Scale Down Resources
      • Start-up/Shutdown Environments
      • Load Balancers
      • Firewalls/ Connection Topology

Benefits of IaC for Business

      • Improved Reliability.
      • Reducing errors and manual configuration.
      • Stable & consistent environments
      • Cost optimization.
      • Self-documenting.
      • Speed and efficiency
      • Alignment with DevOps Framework
      • Version controlled infrastructure

Challenges

§  IaC Requires comprehensive Training & Testing.

§  Any Configuration Change outside IaC Template is difficult to Track

Conclusion

IaC manages Infrastructure using Configuration files. This Code file can be versioned using source control . By adopting IaC we can maintain Consistency, reduce cost and speedy infrastructure set up. With the right automation solution in place, you can deploy new applications and manage and monitor Infrastructure more efficiently.

Related Resources:

Check my How to Guides

Create and Deploy ARM Template

How useful was this post?

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 8

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply