🛠️ Terraform Setup Guide: Install Terraform, AWS CLI & Prepare Your DevOps Environment (Part 2)

In the previous post, we talked about why Terraform matters and how it replaces manual AWS work.

Now it’s time to set up your environment and get ready to build real infrastructure.

🎯 What You’ll Do in This Guide

By the end of this post, you will:

  • Install Terraform
  • Configure AWS CLI
  • Verify your environment
  • Run your first Terraform command

🧰 Environment Used

This guide uses:

WSL Ubuntu / Linux

(You can adapt these steps for macOS or Windows as well.)

🔹 Step 1 — Install Terraform

Run the following commands:

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

wget -O- https://apt.releases.hashicorp.com/gpg | 
gpg --dearmor | 
sudo tee /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

✅ Verify Installation

terraform version

Expected output:

Terraform v1.x.x

🔹 Step 2 — Install AWS CLI

sudo apt install awscli -y

Verify:

aws --version

🔹 Step 3 — Configure AWS Credentials

Run:

aws configure

Enter:

AWS Access Key ID
AWS Secret Access Key
Region (e.g. ap-southeast-1)
Output format (json)

🔍 Test AWS Connection

aws sts get-caller-identity

If successful, you’ll see your AWS account details.

🔹 Step 4 — Create Your First Terraform Project

Create a new folder:

mkdir terraform-test
cd terraform-test

Create a file:

touch main.tf

Add the following:

provider "aws" {
  region = "ap-southeast-1"
}

🔹 Step 5 — Initialize Terraform

Run:

terraform init

Expected output:

Terraform has been successfully initialized!

⚠️ Common Errors (From Real Experience)

❌ AWS credentials not working

Fix:

aws configure

❌ Network / STS error

Check:

aws sts get-caller-identity

❌ Terraform not found

Check:

terraform version

🎯 What You Just Completed

You now have:

  • Terraform installed
  • AWS CLI configured
  • Working environment
  • Verified setup

👉 You are ready to build real infrastructure.

💡 DevOps Insight

A correct setup saves hours of debugging later.

Before writing Terraform code, always verify:

terraform version
aws sts get-caller-identity

🚀 What’s Next?

Now that your environment is ready, let’s build something real.

In the next post, we’ll:

👉 Deploy your first EC2 instance using Terraform
👉 Understand plan and apply in action
👉 See real infrastructure created from code

This is where you move from setup → real DevOps work 🔥

👨‍💻 About the Author

Hi, I’m Ahkar — sharing DevOps, AWS, and Infrastructure knowledge to help others grow 🚀

I publish bilingual content (Myanmar 🇲🇲 + English 🇺🇸) focused on real-world cloud learning.

🌐 Blog: https://mindgnite.com

If you found this helpful, consider following for more Terraform & DevOps content 🔥

📚 Terraform Learning Series

  • Part 1: Why Terraform
  • Part 2: Setup Guide (this post)
  • Part 3: First EC2 Deployment (coming next)

👉 Follow to continue the journey 🚀

Leave a Reply