Skip to main content

Command Palette

Search for a command to run...

πŸ“˜ Terraform Series – Day 2

Updated
β€’3 min read
πŸ“˜  Terraform Series – Day 2
G

Gujjar Apurv is a passionate DevOps Engineer in the making, dedicated to automating infrastructure, streamlining software delivery, and building scalable cloud-native systems. With hands-on experience in tools like AWS, Docker, Kubernetes, Jenkins, Git, and Linux, he thrives at the intersection of development and operations. Driven by curiosity and continuous learning, Apurv shares insights, tutorials, and real-world solutions from his journeyβ€”making complex tech simple and accessible. Whether it's writing YAML, scripting in Python, or deploying on the cloud, he believes in doing it the right way. "Infrastructure is code, but reliability is art."

Terraform Setup on AWS EC2 & Local (Ubuntu , window )

In Day 1, we understood the fundamentals of Terraform and Infrastructure as Code (IaC).
Now, in Day 2, we will set up Terraform in real environments.

This guide covers installation on:

  • AWS EC2 (Ubuntu)

  • Local Ubuntu Machine

  • Windows (using Chocolatey)

🎯 Objective

  • Install Terraform in different environments

  • Follow secure installation practices

  • Verify installation properly

☁️ Part 1: Setup on AWS EC2 (Ubuntu)

🧱 Step 1: Create EC2 Instance

  • Go to AWS EC2 Dashboard

  • Click Launch Instance

  • Select:

    • OS β†’ Ubuntu

    • Instance Type β†’ t2.micro (Free Tier)

  • Create key pair

  • Launch instance

πŸ” Step 2: Connect via SSH

ssh -i your-key.pem ubuntu@your-ec2-public-ip

πŸ“¦ Step 3: Update System

sudo apt-get update && sudo apt-get install -y gnupg software-properties-common

πŸ”‘ Step 4: Add HashiCorp GPG Key

wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null

βœ… Step 5: Verify GPG Key

gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint

πŸ‘‰ Ensures authenticity and security

πŸ“ Step 6: Add Repository

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

πŸ”„ Step 7: Update Packages

sudo apt-get update

βš™οΈ Step 8: Install Terraform

sudo apt-get install terraform

πŸ” Step 9: Verify Installation

terraform --version

πŸ’» Part 2: Local Installation (Ubuntu)

πŸ‘‰ Follow the same steps as EC2

No changes required β€” works exactly the same.

πŸͺŸ Part 3: Terraform Installation on Windows

πŸ“¦ Step 1: Install using Chocolatey

choco install terraform

πŸ‘‰ Make sure Chocolatey is installed on your system

πŸ” Step 2: Verify Installation

Open a new terminal (CMD/PowerShell):

terraform -help

Expected output:

Usage: terraform [global options] <subcommand> [args]

πŸ‘‰ Shows all available Terraform commands

🐧 Bash

touch ~/.bashrc
terraform -install-autocomplete

🐚 Zsh

touch ~/.zshrc
terraform -install-autocomplete

πŸ‘‰ Restart terminal after this step

πŸ“˜ Alternative Installation Method

You can also install Terraform using the official HashiCorp documentation depending on your OS and requirements.

Terraform official Documentation

πŸ‘¨β€πŸ’» About the Author

β€œThis Kubernetes series focuses on building a strong foundation by understanding real Kubernetes concepts step by step.”

πŸ“¬ Let's Stay Connected

Terraform

Part 2 of 12

πŸš€ Terraform Series – Automate Your Infrastructure Starting a complete **Terraform series** where I’ll cover everything from **basic to advanced level** with real-world practicals. In this series, you will learn: β€’ What is Infrastructure as Code (IaC) & why it matters β€’ Terraform fundamentals (providers, resources, state) β€’ Writing and managing Terraform configurations β€’ Variables, outputs & modules β€’ Remote state & state management β€’ Provisioning infrastructure on AWS β€’ Automation & real-world use cases β€’ Advanced concepts like workspaces, modules, and best practices 🎯 Goal: Help you automate infrastructure and become job-ready in DevOps. Perfect for **beginners, students, and DevOps learners** who want hands-on experience. Stay tuned and let’s build infrastructure the smart way βš‘πŸ’» #Terraform #DevOps #Cloud #AWS #InfrastructureAsCode #Automation

Up next

πŸ“˜ Terraform Series – Day 3

Terraform Blocks, Labels, and Arguments In Day 2, we installed Terraform.Now, before writing real infrastructure code, we must understand how Terraform actually reads and executes configurations. πŸ‘‰ E

More from this blog

T

The OpsVerse with Apurv

26 posts

Sharing hands-on DevOps, AWS, and Cloud tutorials with real-world projects, tips, and automation guides for students and professionals.