Skip to main content

Command Palette

Search for a command to run...

πŸš€ Terraform Series – Day 2

Published
β€’3 min read
πŸš€ Terraform Series – Day 2

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 7 of 8

πŸš€ 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 1

Introduction to Terraform & Infrastructure as Code (IaC) In modern DevOps practices, managing infrastructure manually is no longer scalable or efficient. Organizations are rapidly shifting towards aut