Terraform Lab on AWS Free Tier — Beginner to Real-World DevOps
Learn Terraform from scratch by building real AWS infrastructure safely using the AWS Free Tier.

As a seasoned system administrator with a passion for technology and problem-solving, I bring 6 Years of hands-on experience in managing and maintaining IT infrastructure. My journey in the field began with a deep curiosity for computers and systems, which has evolved into a fulfilling career dedicated to ensuring the smooth operation of critical business systems.
Introduction:
Infrastructure as Code (IaC) is one of the most important skills in modern DevOps and Cloud Engineering.
In this hands-on lab, we’ll build a complete AWS infrastructure using Terraform while staying within the AWS Free Tier.
This guide is designed for:
Beginners learning Terraform System Administrators moving into Cloud/DevOps Students and homelab users Anyone wanting practical AWS automation experience
Goal:
Build a safe AWS Free Tier Terraform lab that Creates infrastructure automatically Uses only Free Tier eligible resources Avoids unexpected AWS charges Teaches real-world Terraform basics Can be destroyed easily after testing
What You Will Learn:
In this lab you will learn how to:
Install and configure Terraform Connect Terraform with AWS Create infrastructure using code Deploy: VPC Public Subnet Security Group EC2 Instance (Free Tier) Use Terraform commands Modify infrastructure safely Destroy infrastructure to avoid billing
⚠️ Important AWS Free Tier Safety Rules:
Use ONLY these:
Region: ap-south-1 or us-east-1
EC2 Type: t2.micro or t3.micro One instance only
Small EBS disk (8GB)
Avoid Load Balancers
Avoid NAT Gateway
Avoid RDS for now
Always destroy lab after use Recommended
Create billing alarms
Enable MFA on AWS account
Never use root account for Terraform
Architecture: Terraform will create the following infrastructure:
Internet │ Internet Gateway │ Public Subnet │ EC2 Instance (Ubuntu)
Step 1 — Install Terraform on Windows
Download Terraform: https://developer.hashicorp.com/terraform/downloads
Steps:
Download Windows AMD64 zip
Extract terraform.exe Move it to: C:\terraform
Add the folder to Environment Variables → PATH
Verify Installation terraform -version
Step 2 — Install AWS CLI
Download: https://aws.amazon.com/cli/
Verify AWS CLI
aws --version
Step 3 — Create AWS IAM User for Terraform
⚠️ DO NOT use the root account.
Go to:
AWS Console → IAM → Users → Create User
Username terraform-user
Permissions For lab purposes only: AdministratorAccess
Create Access Key
Click on Save.
Step 4 — Configure AWS CLI
Run:
aws configure
Now Enter:
1. AWS Access Key ID
2. AWS Secret Access Key
3. Region: ap-south-1
4. Output format: json
5. Test AWS Access:aws sts get-caller-identity
Successful AWS CLI authentication
Step 5 — Create Terraform Project
Create folder:
terraform-aws-lab
Inside create file:
main.tf
Project folder structure
Step 6 — Terraform Configuration
download main.tf file from this link:
https://github.com/sanchitpandit/Devops/blob/main/terraform/terraform-lab-aws-free-tier/main.tf
Step 7 — Initialize Terraform
Open PowerShell inside the project folder.
Run:
terraform fmt
terraform init
Expected output:
Terraform has been successfully initialized
Step 8 — Validate Configuration terraform validate
RUN: terraform validate
Step 9 — View Execution Plan terraform plan
Terraform will show all resources it plans to create.
RUN: terraform plan
Step 10 — Deploy Infrastructure
Run:
terraform apply
Type:
yes
Terraform will create:
VPC Public Subnet Route Table Security Group EC2 Instance
Step 11 — Verify in AWS Console
Open:
AWS Console → EC2
Verify:
Running EC2 instance Public IP assigned Security group attached VPC created
Created VPC
Step 12 — Connect to EC2
Windows users can use:
PuTTY Windows Terminal SSH
Example:
ssh ubuntu@PUBLIC-IP
Successful SSH login
Step 13 — Modify Infrastructure
Change:
instance_type = "t3.micro"
To:
instance_type = "t2.micro"
Then run:
terraform plan terraform apply
Terraform will update the infrastructure automatically.
Terraform detecting infrastructure changes
**
Step 14 — Destroy Infrastructure**
⚠️ VERY IMPORTANT
Always destroy lab resources after testing.
terraform destroy
Type:
yes
This prevents unexpected AWS charges.
📌 Important Terraform Commands Command Purpose terraform init Initialize project terraform validate Validate syntax terraform plan Preview changes terraform apply Create/update resources terraform destroy Delete resources terraform fmt Format files terraform state list Show managed resources 🔥
🏢 Real Business Usage of Terraform
Terraform is widely used for:
AWS infrastructure automation Disaster recovery setup Dev/Test environment provisioning Kubernetes infrastructure Multi-cloud deployment Standardized infrastructure Infrastructure version control CI/CD automation 📈 Suggested Learning Path Terraform Basics Variables Modules Remote State Workspaces Terraform Cloud CI/CD Integration Kubernetes with Terraform Production Infrastructure Design ✅ Cleanup Checklist
Before ending the lab:
Run terraform destroy Verify EC2 deleted
- Verify EBS deleted
- Verify VPC deleted
- Verify no Elastic IP remains
- Check AWS Billing Dashboard
🎉 Conclusion:
You now have a working Terraform AWS Free Tier lab environment.
This is the same core workflow used in real-world DevOps and Cloud Engineering environments.
If you’re a Sysadmin or beginner entering DevOps, Terraform is one of the best tools to start with because it teaches:
Cloud infrastructure Automation Version-controlled infrastructure Repeatable deployments Real production workflows
Happy Learning 🚀





