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

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

Step 1: Setting Up AWS Account

Step 4: Installing Terraform

Step 5. Connecting Terraform to AWS

Step 6. Verifying the Setup

Challenges I Faced

What I Learned

Conclusion In my previous post, I talked about what Infrastructure as Code is, why it matters, and why I decided to start learning Terraform. Now it is time to move from understanding to actually setting things up. Before building anything, having the right environment is important. If your setup is not correct, it can slow you down later. So in this post, I will walk through how I set up my Terraform environment and connected it to AWS. I already had an AWS account, so I didn’t need to create a new one. However, I made sure not to use my root account. Instead, I created an IAM user with programmatic access using the AWS console and used it for my setup instead of my root account. This is more secure and is the recommended way to work with AWS. Step 2: Installing AWS CLI Next, I installed AWS CLI on my system. After installation, I checked that it was working by verifying the version. This confirmed that AWS CLI was installed correctly. Step 3: Checking the credentials

After installing AWS CLI, I configured it using my IAM user credentials. I did this by running aws configure and following the prompts. To confirm everything worked, I checked my AWS identity. It returned my account details, which showed that my setup was correct. I installed Terraform on my system and confirmed it was working by checking the version. During this step, I noticed that my Terraform version was outdated. I am currently fixing this by downloading the latest version from the official

Terraform website. Terraform uses the AWS credentials configured through AWS CLI. To make sure everything was working properly, I ran checks to confirm: Terraform is installed AWS authentication is working AWS configuration is correct Everything worked as expected, which means my environment is ready. The main issue I encountered was that my Terraform version was outdated. I discovered this while verifying my setup and started fixing it by installing the latest version. From this setup, I learned how Terraform connects to AWS through AWS CLI. I also understood why using an IAM user is important instead of using root credentials. It improves security and gives better control over access. From everything, using the AWS CLI is more secured than flexible than clicking the AWS console. If this resonates with you, feel free to share it with others on a similar journey. How to Deploy a Kubernetes App on AWS EKS The Best AWS Services to Deploy Front-End Applications in 2025 What is Backend as a Service (BaaS)? A Beginner's Guide The Hidden Challenges of Building with AWS How to Create a CI/CD Pipeline Using AWS Elastic Beanstalk Stay updated with my projects by following me on Twitter, LinkedIn, and GitHub. Thank you for reading Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install awscli -y -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install awscli -y -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install awscli -y aws --version aws --version aws --version terraform version aws --version aws sts get-caller-identity aws configure list terraform version aws --version aws sts get-caller-identity aws configure list terraform version aws --version aws sts get-caller-identity aws configure list Terraform v1.14.7 on linux_amd64 + provider registry.terraform.io/hashicorp/aws v6.36.0 aws-cli/2.22.12 Python/3.12.6 Linux/6.6.87.2-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 { "UserId": "AXXXXXXXXXXXXXXXXXXXV", "Account": "2xxxxxxxxxxxx4", "Arn": "arn:aws:iam::2xxxxxxxxxxx4:user/onyi" } Name Value Type Location ---- ----- ---- -------- profile <not set> None None access_key ****************5SNW shared-credentials-file secret_key ****************KJtJ shared-credentials-file region eu-west-1 config-file ~/.aws/config Terraform v1.14.7 on linux_amd64 + provider registry.terraform.io/hashicorp/aws v6.36.0 aws-cli/2.22.12 Python/3.12.6 Linux/6.6.87.2-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 { "UserId": "AXXXXXXXXXXXXXXXXXXXV", "Account": "2xxxxxxxxxxxx4", "Arn": "arn:aws:iam::2xxxxxxxxxxx4:user/onyi" } Name Value Type Location ---- ----- ---- -------- profile <not set> None None access_key ****************5SNW shared-credentials-file secret_key ****************KJtJ shared-credentials-file region eu-west-1 config-file ~/.aws/config Terraform v1.14.7 on linux_amd64 + provider registry.terraform.io/hashicorp/aws v6.36.0 aws-cli/2.22.12 Python/3.12.6 Linux/6.6.87.2-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 { "UserId": "AXXXXXXXXXXXXXXXXXXXV", "Account": "2xxxxxxxxxxxx4", "Arn": "arn:aws:iam::2xxxxxxxxxxx4:user/onyi" } Name Value Type Location ---- ----- ---- -------- profile <not set> None None access_key ****************5SNW shared-credentials-file secret_key ****************KJtJ shared-credentials-file region eu-west-1 config-file ~/.aws/config - Default region - Terraform is installed - AWS CLI is installed - AWS authentication is working - AWS configuration is correct - How to Deploy a Kubernetes App on AWS EKS - The Best AWS Services to Deploy Front-End Applications in 2025 - What is Backend as a Service (BaaS)? A Beginner's Guide - The Hidden Challenges of Building with AWS - Play with Kubernetes - Docker 101 Tutorial - How to Create a CI/CD Pipeline Using AWS Elastic Beanstalk