DEV Community

Cover image for 🌱 Day 01 – Introduction to Terraform & Infrastructure as Code
Amit Kushwaha
Amit Kushwaha

Posted on

🌱 Day 01 – Introduction to Terraform & Infrastructure as Code

My notes and learnings from Day 01 of #30DaysOfAWSTerraform

Today I started Day 01 of the 30 Days of AWS Terraform challenge by Piyush Sachdeva, and this session gave me my very first look into Terraform and Infrastructure as Code (IaC). Even though it was the introductory lesson, it helped me finally understand why IaC matters and how Terraform fits perfectly into modern cloud and DevOps workflows.

🌐 What Is Infrastructure as Code (IaC)?

Infrastructure as Code (IaC) is a way of managing cloud infrastructure using code instead of manually configuring everything from the AWS console.

With IaC, your setup becomes:
βœ” Predictable
βœ” Repeatable
βœ” Automated
βœ” Version-controlled
βœ” Easy to recreate in any environment

Basically, IaC removes human error and brings structure to infrastructure management.

πŸ› οΈ What Is Terraform?

Terraform is an open-source IaC tool created by HashiCorp. It lets you define infrastructure using configuration files written in HCL (HashiCorp Configuration Language).

🌟 Key points I learned:

  • Terraform supports multi-cloud: AWS, Azure, GCP, Kubernetes, and more
  • It follows a declarative approach β€” define what you want, Terraform decides how to build it
  • It tracks real resources through a state file (terraform.tfstate)
  • It automates provisioning and prevents manual mistakes
  • Terraform becomes the single source of truth for your cloud infrastructure.

One thing that stood out to me was Terraform's state file. Terraform stores the details of all created resources inside a file called terraform.tfstate. This helps Terraform understand what already exists and what changes need to be made.

Terraform Workflow:
The core Terraform workflow, which is actually very simple:-

  1. Write -> Create .tf file.
  2. Init -> Downloads provider plugins.
  3. Plan -> Shows what Terraform will create or modify.
  4. Apply -> Makes the actual changes in your cloud account.
  5. Destroy -> Declares everything when you're done. This workflow makes Terraform predictable and safe.
write -> Init -> Plan -> Apply -> Destroy
Enter fullscreen mode Exit fullscreen mode
       +----------------------+
       |  Terraform Config    |
       |      (.tf files)     |
       +----------+-----------+
                  |
                  v
       +----------------------+
       |   terraform init     |
       | (download providers) |
       +----------+-----------+
                  |
                  v
       +----------------------+
       |   terraform plan     |
       |  (preview changes)   |
       +----------+-----------+
                  |
                  v
       +----------------------+
       |   terraform apply    |
       | (create resources)   |
       +----------+-----------+
                  |
                  v
       +----------------------+
       | Cloud Infrastructure |
       +----------------------+

Enter fullscreen mode Exit fullscreen mode

πŸ“¦ Simple Terraform Example (From Day 01)
Here’s a basic configuration that creates an EC2 instance in AWS:

resource "aws_instance" "my_ec2" {
  ami           = "ami-0e472ba40eb589f49"   # Amazon Linux 2 AMI (ap-south-1)
  instance_type = "t2.micro"                # Free-tier eligible

  tags = {
    Name = "AWS_Terraform_EC2_Instance"
  }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
shaik_zilanbasha_6679014 profile image
Shaik Zilan Basha

Very informative...
Kindly tag me for further notes.