Labs ICT
โญ Pro Login

Infrastructure as Code

Managing infrastructure through version-controlled configuration files

2 min read | DevOps
โญ

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

Infrastructure as Code (IaC)

Infrastructure as Code is the practice of managing and provisioning computing infrastructure through machine-readable configuration files, rather than through manual processes or interactive tools.

Manual vs IaC


  Manual Setup (Snowflake Servers):
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚  SSH into server             โ”‚
  โ”‚  Install packages manually   โ”‚
  โ”‚  Copy config files           โ”‚
  โ”‚  "Works on my server!"       โ”‚
  โ”‚  - No version history       โ”‚
  โ”‚  - Not reproducible          โ”‚
  โ”‚  - Drift over time           โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  Infrastructure as Code:
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚  main.tf / playbook.yml      โ”‚
  โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€       โ”‚
  โ”‚  - Version controlled (Git)  โ”‚
  โ”‚  - Reproducible environments โ”‚
  โ”‚  - Consistent every time     โ”‚
  โ”‚  - Self-documenting          โ”‚
  โ”‚  - Automated provisioning    โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

IaC Tools

  • Terraform โ€” Multi-cloud, declarative, uses HCL language
  • AWS CloudFormation โ€” AWS-native, JSON/YAML templates
  • Ansible โ€” Agentless, uses YAML playbooks for configuration management
  • Pulumi โ€” Uses real programming languages (Python, TypeScript, Go)
  • Chef/Puppet โ€” Agent-based configuration management

Terraform Example


  # Create an AWS EC2 instance
  resource "aws_instance" "web" {
    ami           = "ami-0c55b159cbfafe1f0"
    instance_type = "t2.micro"

    tags = {
      Name = "WebServer"
      Environment = "production"
    }
  }

  # What this does:
  # 1. Declaratively describes desired state
  # 2. Terraform plans changes before applying
  # 3. Tracks state to detect drift
  # 4. Can destroy resources when no longer needed

IaC Benefits

  • Reproducibility โ€” Spin up identical environments in minutes
  • Version control โ€” Track infrastructure changes in Git
  • Speed โ€” Automate provisioning that took days manually
  • Reliability โ€” Eliminate human error from manual configuration
  • Documentation โ€” Code IS the documentation

๐Ÿงช Quick Quiz

Infrastructure as Code (IaC) means: