Day 1: Introduction to Terraform

DevOps Enginner
What is Terraform?
Terraform is an open-source Infrastructure as Code (IaC) tool created by HashiCorp.
It allows you to define, provision, and manage infrastructure using simple configuration files instead of manual clicks.
With Terraform, infrastructure becomes:
Version-controlled
Repeatable
Predictable
Automated
Why Terraform is Used in Modern Tech Industry
Modern systems are:
Cloud-native
Multi-region
Microservice-based
Fast-scaling
Terraform helps teams:
Provision infra in minutes instead of hours
Avoid manual configuration mistakes
Maintain consistency across environments (dev, staging, prod)
Collaborate using Git-based workflows
Scale infrastructure safely
Popular IaC Tools (Terraform vs Others)
| Tool | Scope |
| Terraform | Multi-cloud (AWS, Azure, GCP, more) |
| Pulumi | IaC using programming languages |
| AWS CloudFormation | AWS only |
| AWS CDK | AWS only (code-based IaC) |
| AWS SAM | AWS serverless deployments |
| Azure ARM / Bicep | Azure only |
| GCP Config Controller | GCP only |
Why Do We Need Terraform?
Without Terraform:
Infrastructure is created manually
No clear documentation of infra
Hard to reproduce environments
Changes are risky and error-prone
With Terraform:
Infra lives as code
Easy rollback and audit
Same config works across environments
Infrastructure becomes part of CI/CD
Challenges Without IaC
“It works on my machine” issues
Environment drift
Manual misconfigurations
Slow deployments
No single source of truth
Terraform eliminates these problems.
Where Terraform is Mostly Used
Cloud infrastructure provisioning
Kubernetes clusters
Networking (VPCs, subnets, gateways)
Databases and storage
CI/CD pipeline infra
Multi-region deployments
Terraform Installation Guide
Linux
sudo apt update
sudo apt install -y wget unzip
wget https://releases.hashicorp.com/terraform/1.9.0/terraform_1.9.0_linux_amd64.zip
unzip terraform_1.9.0_linux_amd64.zip
sudo mv terraform /usr/local/bin/
terraform version
windows
Download Terraform from official site
Extract
terraform.exeAdd it to System PATH
verify in cmd:- terraform version
Other methods
# For macOS
brew install hashicorp/tap/terraform
# For Ubuntu/Debian
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
Setup Commands
terraform -install-autocomplete
alias tf=terraform
terraform -version
Common Installation Error (macOS)
If you encounter: Error: No developer tools installed.
Install Command Line Tools:
xcode-select --install
For more details visit my github repo:- https://github.com/sidharthhhh/terraform
https://github.com/piyushsachdeva/Terraform-Full-Course-Aws/tree/main/lessons/day01
For more detail explaination watch:- https://youtu.be/s5fwSG_00P8?si=bj9kYlOZH3Q6Eawy




