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 π
Top comments (0)