Logo The AI Dev
Back to Article
Deep Dive Note

Understanding Infrastructure as Code (IaC)

Day 1: Understanding Infrastructure as Code (IaC)

Welcome to Day 1 of our 30-Day journey into Terraform and AWS! Today, we lay the foundation. Before we write a single line of Terraform code, we must grasp the fundamental shift in paradigm that is Infrastructure as Code (IaC). This isn’t just a buzzword; it’s a philosophy that underpins modern DevOps and Cloud Engineering.

What is Infrastructure as Code?

At its core, Infrastructure as Code is the practice of managing and provisioning computing infrastructure (like servers, networks, databases, etc.) through machine-readable definition files, rather than through physical hardware configuration or interactive configuration tools.

Think of it like this: instead of manually clicking through the AWS console to create a virtual machine (an EC2 instance), you define the desired state of that machine in a configuration file. An IaC tool then reads this file and makes the necessary API calls to the cloud provider to create, update, or delete resources to match your definition.

The Core Dependency: The Cloud Provider API

The entire concept of IaC for cloud resources hinges on one critical dependency: the Cloud Provider’s Application Programming Interface (API).

Every action you can perform in the AWS Management Console—launching an EC2 instance, creating an S3 bucket, configuring a VPC—is ultimately an API call under the hood. The console is just a user-friendly graphical interface for those APIs.

IaC tools like Terraform are essentially sophisticated API clients. They provide a structured, high-level language for you to define your infrastructure, and then they translate that into the specific, often complex, sequence of API calls required to make it a reality.

+-----------------------+      +----------------------+      +---------------------+
|      You (The User)   |      |   IaC Tool           |      |   Cloud Provider    |
|                       |      |   (e.g., Terraform)  |      |   (e.g., AWS)       |
+-----------------------+      +----------------------+      +---------------------+
           |                             |                             |
           |   Defines desired state     |                             |
           |   in a config file          |                             |
           +---------------------------> |  Reads config file          |
           |                             |                             |
           |                             |  Translates to API calls    |
           |                             +---------------------------> |  Executes API calls |
           |                             |                             |
           |                             |                             |  Provisions/modifies |
           |                             |                             |  infrastructure      |
           |                             |                             |
           |                             |  Returns state              |
           |                             <---------------------------+
           |                             |
           |  Sees provisioned           |
           |  infrastructure             |
           <-----------------------------+

The “Why”: Why Do We Need IaC?

To truly appreciate IaC, let’s look at the “Old Way” of managing infrastructure, often referred to as the Traditional or Manual Approach.

The Traditional Approach: “ClickOps”

Imagine you’re a System Administrator a decade ago. Your task is to deploy a new web application. Your workflow would look something like this:

  1. Procurement: Order physical servers. Wait for them to arrive.
  2. Racking and Stacking: Install the servers in a data center. Connect power, networking, etc.
  3. OS Installation: Manually install the operating system from a CD/DVD.
  4. Configuration: Manually configure the OS, install dependencies, and set up networking.
  5. Application Deployment: Copy the application files and configure the web server.

Even with the advent of the cloud, this manual process often persisted, just in a virtualized form. We traded physical servers for virtual machines, but the process was still manual: clicking through the AWS/Azure/GCP console to provision and configure resources. This is often jokingly referred to as “ClickOps”.

Challenges with the Traditional Approach

This manual approach is fraught with problems, especially as infrastructure scales:

IaC as the Solution

IaC directly addresses these challenges:


Scenario: The “Drift” Problem

Let’s consider a real-world scenario. Your team has a production environment running on AWS, initially provisioned with IaC. A developer, trying to debug a critical issue, manually changes a security group rule in the AWS console to allow traffic from their IP address. They forget to revert the change.

This is called configuration drift: the actual state of your infrastructure has “drifted” from the state defined in your code.

Solution with IaC:

Modern IaC tools like Terraform can detect this drift. When you run a terraform plan, it will compare the real-world state of your infrastructure with the state defined in your code and show you the difference. It will highlight the unauthorized security group rule and allow you to revert it, bringing your infrastructure back into compliance.

This ability to detect and correct drift is one of the most powerful features of IaC.


This foundational understanding of what IaC is and why it’s so critical will serve you well as we dive deeper into Terraform in the coming days. In our next section, we’ll focus specifically on Terraform and its benefits. a