What is Infrastructure as Code (IaC) and why is it important?
Infrastructure as Code (IaC) is a method of managing and provisioning infrastructure using code instead of manual processes. It allows:
✅ Automation of infrastructure deployment
✅ Consistency by reducing human errors
✅ Scalability through repeatable scripts
What is Terraform and how does it work?
Terraform is an open-source IaC tool by HashiCorp that helps define and provision infrastructure using a declarative configuration language. It follows three steps:
Write: Define infrastructure in .tf files
Plan: Preview changes before applying
Apply: Deploy and manage resources
Example:
provider "aws" { region = "us-east-1"}resource "aws_instance" "my_instance" { ami = "ami-12345678" instance_type = "t2.micro"}
What is the difference between Terraform and Ansible?
Feature
Terraform
Ansible
Type
Declarative
Imperative
Purpose
Infrastructure provisioning
Configuration management
State Management
Uses state file
Stateless
Example Use
Creating VMs, Networks
Installing software, configuring OS
What are Terraform Providers?
Providers are plugins that allow Terraform to manage resources on different platforms (AWS, Azure, GCP, Kubernetes, etc.).
Example:
provider "aws" { region = "us-west-2"}
What is a Terraform State File?
Terraform maintains infrastructure details in a state file (terraform.tfstate), which:
✅ Tracks existing resources
✅ Enables incremental changes
✅ Supports remote storage (e.g., S3, Azure Blob)
Ansible is an open-source configuration management tool that automates tasks like software installation, updates, and deployments. It works agentless, using SSH or WinRM.
What are Ansible Playbooks?
A playbook is a YAML-based automation script that defines tasks to be executed.