Skip to main content

Command Palette

Search for a command to run...

Day 61 – Introduction to Terraform and My First AWS Infrastructure ☁️

Updated
4 min read
H
I am an MCA (Cloud Computing) student at MIT ADT University, focused on becoming a DevOps & Cloud Engineer who builds reliable, scalable, and automated systems. 🏆 5× Hackathon Winner — Hacktoberfest Hackathon, Innovyuh Hackathon – Solution Challenge, Build with AI (GDG Cloud Pune), Project Innovista (Research & Project Competition), NASA International Space Apps Challenge. I work at the intersection of development and operations, where I design, automate, and manage cloud infrastructure: • Cloud & Linux: AWS (EC2, S3, VPC) and Linux system management • Infrastructure as Code: Terraform & Ansible • Containers & Orchestration: Docker & Kubernetes • CI/CD: Jenkins & GitHub Actions • Monitoring & SRE: Prometheus, Grafana, ELK, OpenTelemetry Beyond building, I actively write about DevOps and Cloud to simplify complex concepts and share practical knowledge. I am currently looking for opportunities where I can contribute, learn from industry experts, and grow into a high-impact DevOps Engineer.

On Day 61 of my 90 Days of DevOps journey, I started learning Terraform and Infrastructure as Code (IaC).

Until now, I was mainly working with Docker, Kubernetes, CI/CD, and deployments.

But today I explored something very important in DevOps:

How cloud infrastructure itself is created using code.

This was my first hands-on experience creating AWS resources using Terraform instead of manually clicking inside the AWS Console.

Infrastructure as Code (IaC)

Before starting Terraform practically, I first learned what Infrastructure as Code means.

Infrastructure as Code is the process of managing infrastructure using configuration files instead of manually creating resources.

Instead of creating:

EC2 instances
S3 buckets
networks
security groups

manually from the AWS Console, Terraform allows us to define everything inside code files.

This makes infrastructure:

repeatable
version-controlled
automated
consistent

I also understood why IaC is so important in DevOps.

Manual infrastructure creation can lead to:

human errors
inconsistent environments
difficult scaling
hard recovery

IaC solves these problems by automating infrastructure provisioning.

Installing Terraform and AWS CLI

Next, I installed:

Terraform
AWS CLI

Then I configured AWS credentials using:

aws configure

and verified access using:

aws sts get-caller-identity

That was my first successful connection between my local machine and AWS using CLI tools.

Creating My First Terraform Project

Then I created my first Terraform project directory and wrote a:

main.tf

file.

Inside the file, I configured:

AWS provider
AWS region
S3 bucket resource

Then I ran the Terraform workflow:

terraform init
terraform plan
terraform apply

When I executed:

terraform apply

Terraform created my AWS S3 bucket automatically.

Seeing cloud infrastructure get created directly from code felt really exciting ☁️🔥

Understanding terraform init

Today I also learned what:

terraform init

actually does.

It downloads:

  • required provider plugins

  • creates the .terraform directory

  • prepares the working directory

This step initializes the Terraform project before provisioning resources.

Creating an EC2 Instance

Next, I added an EC2 instance inside the same:

main.tf

file.

I configured:

Amazon Linux 2 AMI
t2.micro instance
custom Name tag

Then I ran:

terraform plan

again.

Terraform only showed the EC2 instance for creation because the S3 bucket already existed.

That helped me understand how Terraform tracks infrastructure using the:

terraform.tfstate

file.

Understanding Terraform State

One of the most important things I learned today was the Terraform state file.

Terraform stores all infrastructure details inside:

terraform.tfstate

This file contains:

  • resource IDs

  • configurations

  • metadata

  • current infrastructure state

Using:

terraform state list

and:

terraform state show

I explored how Terraform tracks resources internally.

I also learned:

  • never manually edit the state file

  • never push state files to GitHub

because they may contain sensitive information.

Modify, Plan, and Destroy

Finally, I modified the EC2 instance tag inside:

main.tf

Then I ran:

terraform plan

again.

Terraform clearly showed what changes would happen before applying them.

I also learned Terraform symbols:

  • → create
    ~ → modify

  • → destroy

At the end, I deleted all infrastructure using:

terraform destroy

and AWS resources were removed automatically.

That was honestly one of the coolest parts today.

What I Learned Today

Today I learned:

Infrastructure as Code (IaC)
Terraform basics
AWS provider
terraform init
terraform plan
terraform apply
terraform destroy
Terraform state file
AWS S3 bucket creation
EC2 provisioning using code

Final Thoughts

Today was a very important step in my DevOps journey because I finally understood how infrastructure automation works.

Instead of manually creating cloud resources, Terraform allows everything to be managed using code.

Creating and destroying AWS infrastructure from the terminal felt really powerful

TerraWeek officially started

See you on Day 62.