DEV Community

James Kipsoi
James Kipsoi

Posted on

Step-by-Step Guide to Setting Up Terraform, AWS CLI, and Your AWS Environment

Hi there,

Today I am going to take you through the process of setting up Terraform, AWS CLI, and your AWS environment for your DevOps journey.

But honestly… don’t you think there are already way too many tutorials, blogs, and videos about this? Just search “Terraform setup” and watch your screen become instantly messy with suggestions.

It is honestly surprising you clicked this one.
A glass of milk for both you and me

Now, I will not pretend that this guide is magically different from the others. I am just a student DevOps engineer trying to complete a challenge assignment, so forgive me if I sound slightly dramatic along the way.

Still, this is the exact process I followed.

Step 1 — Create an AWS Account

I started by creating an AWS Free Tier account.

A few important things I quickly learned:

Always enable billing alerts or budgets early.
Never casually leave EC2 instances running.
Avoid using the root account for daily activities.

AWS gives enough free resources to learn comfortably, but cloud bills can become dangerous surprisingly fast.

I also decided to use a separate IAM user instead of the root account for better security practices.

Step 2 — Install Terraform

For Terraform, I followed the official HashiCorp installation guide:

Terraform Install Guide

Since I use Ubuntu/Linux, I used the Linux installation method.

After installation, I verified Terraform using:

terraform version

Output:

Terraform v1.14.5
on linux_amd64

  • provider registry.terraform.io/hashicorp/aws v6.44.0

Terraform also informed me that a newer version was available, but the installed version worked perfectly fine for the labs.

Step 3 — Install AWS CLI

Next, I installed AWS CLI using the official AWS documentation:

AWS CLI Quickstart Guide

After installation, I configured my credentials using:

aws configure

I entered:

Access Key
Secret Access Key
Default region
Output format

For my region, I chose one close to me and commonly used for learning labs.

To confirm everything was working correctly, I ran:

aws sts get-caller-identity

Output:

{
"UserId": "AIDAZ24IS2U2RF5HSEXOK",
"Account": "676206925109",
"Arn": "arn:aws:iam::676206925109:user/demo-user"
}

This confirmed that my AWS CLI authentication was properly configured.

Common Errors and Quick Fixes

Even though setup is usually straightforward, people still find creative ways to break things. Here are some common problems and fixes:

  1. Terraform Command Not Found

Problem:

terraform: command not found

Fix:
Terraform is either not installed correctly or not added to your PATH.

  1. AWS Credentials Not Working

Problem:

Unable to locate credentials

Fix:
Run:

aws configure

and enter valid credentials.

  1. Access Denied Errors

Problem:
IAM user lacks permissions.

Fix:
Attach the required IAM policies or use a user with proper permissions.

  1. Unexpected AWS Charges

Problem:
Leaving resources running accidentally.

Fix:
Always destroy unused infrastructure and set AWS Budgets alerts.

Final Thoughts

The setup process was actually smoother than I expected.

The most interesting part was seeing how Terraform and AWS CLI work together to automate infrastructure management. Once the environment was ready, I could already see how much faster Infrastructure as Code is compared to manually configuring cloud resources through the AWS console.

Read the docs before starting a 4-hour debugging side quest
Peace.
-lelkiramkeel

Top comments (0)