DEV Community

Cover image for πŸ› οΈ Terraform Setup Guide: Install Terraform, AWS CLI & Prepare Your DevOps Environment (Part 2)
Ahkar Swe
Ahkar Swe

Posted on

πŸ› οΈ 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
Enter fullscreen mode Exit fullscreen mode

βœ… Verify Installation

terraform version
Enter fullscreen mode Exit fullscreen mode

Expected output:

Terraform v1.x.x
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 2 β€” Install AWS CLI

sudo apt install awscli -y
Enter fullscreen mode Exit fullscreen mode

Verify:

aws --version
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 3 β€” Configure AWS Credentials

Run:

aws configure
Enter fullscreen mode Exit fullscreen mode

Enter:

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

πŸ” Test AWS Connection

aws sts get-caller-identity
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Create a file:

touch main.tf
Enter fullscreen mode Exit fullscreen mode

Add the following:

provider "aws" {
  region = "ap-southeast-1"
}
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 5 β€” Initialize Terraform

Run:

terraform init
Enter fullscreen mode Exit fullscreen mode

Expected output:

Terraform has been successfully initialized!
Enter fullscreen mode Exit fullscreen mode

⚠️ Common Errors (From Real Experience)

❌ AWS credentials not working

Fix:

aws configure
Enter fullscreen mode Exit fullscreen mode

❌ Network / STS error

Check:

aws sts get-caller-identity
Enter fullscreen mode Exit fullscreen mode

❌ Terraform not found

Check:

terraform version
Enter fullscreen mode Exit fullscreen mode

🎯 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
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)