Infrastructure as Code

Infrastructure as a Code

Software Development has become very dynamic and vibrant. Application corrective actions, enhancements are expected to be done in minimal time. Agile development and DevOps as part of CI/CD has become integral part of Software Development Life Cycle. In response to make SDLC easier, faster, stable, consistent and robust, many tools & processes are created focusing on specific problem of the complete life cycle.

Cloud Infrastructure is one such area which makes digital infra (like servers, database, networks, storage, monitoring etc) creation for different environments (like development, testing, integration or release) very easy, fast, robust and secure. Along with it, Cloud Infrastructure also enables us to create (setup) physical infrastructure through service APIs and like a software installation. Writing software or service APIs for creation, change or destruction of Digital Infra actually means, we are moving towards Infrastructure as Code.

Infrastructure as Code is a process for management, provision and orchestration of digital infrastructure with writing of code files (descriptive models) or software APIs. This uses the similar syntax & source code versioning as used by other tools in DevOps and development. It’s a code written to automate digital infrastructure and configuration management. Infrastructure as Code (IaC) is in alignment and conjunction with Infrastructure as a Service (IaaS) and Continuous Deployment (CD).

IaC Principle of Idempotence

IaC works with the core principle of Idempotence. Idempotence property is used in mathematics and computer science terminologies, which means end result will be always be same, irrespective of the property is applied multiple times. With this principle in IaC means, end result (state) of Infrastructure will remain same irrespective of environment or initial configuration (state) of environment. This is very useful when multiple environments (like development, testing, integration) with similar configuration settings are required in different stages of software development.

IaC Benefits

IaC provides many advantages (benefits). All the benefits provided helps in three measurable categories : 

Cost Reduction, Speed (Faster Execution), Risk (remove errors & security violations)

  1. IaC enables source control (versioning) of infrastructure. This makes us to track changes happening in the infrastructure and also enables to use previous versions if required (in case of rollback or some issues). Helps in reducing risk of failure.
  2. Code versioning of Infra, also helps in reviewing and auditing of Infra without actually provisioning it. Helps in cost reduction. 
  3. Different environments (development, testing, integration) can be provisioned immediately (faster execution) and only when required (reduce cost). 
  4. Principle of Idempotence, helps to solve the problem of environment drift. 
  5. Avoids environmental snowflake & inconsistency

Environment drift is defined for increase in difference between configurable state of different environments with every deployment or change in configuration. For example, if development and testing environment starts as new machines and with same configuration. But, with every new deployment lead to difference in their configurations state. Slowly but steadily, after certain period of time, difference becomes significant and environments are inconsistent. Both environments starts behaving differently for application functionality. Application functionality working on one environment but not on other. This leads to conflict between dev and testing teams and confusion over the function implementation.

IaC ensures that state of environment will be same as it was expected, doesn’t matter what its initial state was.

IaC Approaches

Three approaches (What, How and Why) are decided by IaC while provisioning of infrastructure. These approaches are also knows as Declarative (functional, What), Imperative (procedural, How) & Intelligent (environment aware, Why).

  1. Declarative approach focuses on the target configuration and check for what needs to do to achieve the desired state
  2. Imperative approach focuses on how the infrastructure needs to change. It finds out the procedure (APIs) to call to achieve the desire state.
  3. Intelligent approach focuses on why something has to be done. It checks for dependencies & co-relations. It ensures to maintain the required state so dependencies are maintained and managed.

IaC Tools

There are many tools that provides the IaC automation capabilities. Every major cloud providers like AWS, Azure, GCP provide their specific tools for IaC. They also provide support for other common tools for infra creation in their services.

  1. Cloud Formation for AWS
  2. Azure Platform Manager for Azure
  3. Google Deployment Manager
  4. Terraform
Cloud Computing

Cloud Computing & It’s Growth

In the past few years, “Cloud” is the most frequently used term in IT Industry. Even, “Cloud and Cloud Computing”...

Terraform Quiz

Terraform Quiz 2

Interview Quiz on Terraform Questions & Answers for Terraform Interview Preparation

Infrastructure as a Code

Infrastructure as Code

Software Development has become very dynamic and vibrant. Application corrective actions, enhancements are expected to be done in minimal time....