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)
- 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.
- Code versioning of Infra, also helps in reviewing and auditing of Infra without actually provisioning it. Helps in cost reduction.
- Different environments (development, testing, integration) can be provisioned immediately (faster execution) and only when required (reduce cost).
- Principle of Idempotence, helps to solve the problem of environment drift.
- 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).
- Declarative approach focuses on the target configuration and check for what needs to do to achieve the desired state
- Imperative approach focuses on how the infrastructure needs to change. It finds out the procedure (APIs) to call to achieve the desire state.
- 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.
- Cloud Formation for AWS
- Azure Platform Manager for Azure
- Google Deployment Manager
- Terraform
