π± TerraWeek Challenge β Day 1
Introduction to Infrastructure as Code (IaC) & Terraform Basics
π Date: 12 July 2026
Welcome to Day 1 of my TerraWeek Challenge! π
Today was all about understanding Infrastructure as Code (IaC), learning the fundamentals of Terraform, and provisioning my first resource locally. Although the project itself was simple, it helped me understand the workflow that powers modern infrastructure automation.
π― Learning Objectives
By the end of Day 1, I was able to:
- Understand what Infrastructure as Code (IaC) is.
- Learn why Terraform is one of the most popular IaC tools.
- Install and configure Terraform.
- Learn Terraform's core workflow.
- Understand important Terraform concepts.
- Create and destroy my first infrastructure.
- Explore OpenTofu and Terraform's lock file.
π Why Infrastructure as Code?
Before writing any Terraform configuration, I wanted to understand why Infrastructure as Code exists.
Managing cloud infrastructure manually through a web console may work for a personal project, but it quickly becomes difficult as projects grow.
Some common problems with manual infrastructure are:
- Human errors while configuring resources.
- Difficulty recreating the exact same environment.
- Poor collaboration among teams.
- No version history for infrastructure changes.
- Slow deployments.
Infrastructure as Code solves these problems by allowing infrastructure to be written, reviewed, and version-controlled just like application code.
Instead of remembering every click in a cloud console, everything is defined inside configuration files that can be executed repeatedly.
π What is Terraform?
Terraform is an open-source Infrastructure as Code (IaC) tool developed by HashiCorp.
It uses HashiCorp Configuration Language (HCL) to describe the desired infrastructure, and Terraform automatically determines the changes required to reach that desired state.
One of Terraform's biggest strengths is that it is provider agnostic, meaning the same tool can manage resources across:
- AWS
- Azure
- Google Cloud
- Docker
- Kubernetes
- GitHub
- Cloudflare
- DigitalOcean
- VMware
- Hundreds of other providers
β Why Terraform?
Terraform has become one of the industry's most widely adopted Infrastructure as Code tools because it offers:
- Declarative configuration
- Multi-cloud support
- Huge provider ecosystem
- State management
- Reusable modules
- Version-controlled infrastructure
- Easy CI/CD integration
βοΈ Terraform vs Alternatives
| Tool | Comparison |
|---|---|
| Terraform | Multi-cloud Infrastructure as Code using HCL |
| OpenTofu | Community-driven open-source fork of Terraform |
| Pulumi | Uses programming languages like Python and Go instead of HCL |
| CloudFormation | AWS-only Infrastructure as Code service |
| Ansible | Primarily used for configuration management rather than provisioning infrastructure |
π Installing Terraform
The first practical step was installing the latest version of Terraform.
After installation, I verified everything using:
terraform version
terraform -help
Terraform Version
Terraform Help
VS Code Extension
To improve the development experience, I installed the official HashiCorp Terraform Extension.
Features include:
- Syntax Highlighting
- IntelliSense
- Auto Completion
- Formatting
- Validation
Screenshot
π Important Terraform Terminologies
Before creating any infrastructure, I learned the six core concepts that form the foundation of every Terraform project.
Provider
A provider is a plugin that allows Terraform to communicate with a specific platform.
Example:
provider "aws" {
region = "ap-south-1"
}
Resource
A resource represents any infrastructure object managed by Terraform.
Example:
resource "local_file" "example" {
filename = "hello.txt"
content = "Hello Terraform"
}
State
Terraform stores information about all managed resources inside a file named:
terraform.tfstate
The state file allows Terraform to understand what already exists and what changes need to be made.
Plan
Before applying any changes, Terraform generates an execution plan showing exactly what will happen.
terraform plan
This provides an additional safety check before modifying infrastructure.
HCL
HCL (HashiCorp Configuration Language) is the language used to write Terraform configurations.
Example:
resource "random_pet" "name" {
length = 2
}
Module
A module is a reusable collection of Terraform configuration.
Instead of rewriting the same infrastructure repeatedly, modules allow configurations to be packaged and reused.
Example:
module "network" {
source = "./modules/network"
}
π My First Terraform Workflow
The challenge uses the local and random providers, allowing me to learn Terraform without needing a cloud account.
I followed the complete Terraform workflow.
Step 1 β Initialize Terraform
terraform init
Terraform downloaded the required providers and initialized the project.
Step 2 β Format Code
terraform fmt
Automatically formatted the Terraform configuration files.
Step 3 β Validate Configuration
terraform validate
Terraform checked the configuration for syntax errors.
Step 4 β Preview Changes
terraform plan
Terraform displayed the execution plan before creating any resources.
Step 5 β Apply Configuration
terraform apply
Terraform created the required resources.
Generated Output
cat greeting.txt
The local file was successfully created.
Step 6 β Destroy Infrastructure
terraform destroy
Terraform removed every resource it had created.
π Terraform Workflow
Write Configuration
β
βΌ
terraform init
β
βΌ
terraform fmt
β
βΌ
terraform validate
β
βΌ
terraform plan
β
βΌ
terraform apply
β
βΌ
terraform destroy
π« Bonus Exploration
Enable CLI Autocomplete
terraform -install-autocomplete
OpenTofu
OpenTofu is a community-driven fork of Terraform that remains fully open source while maintaining compatibility with existing Terraform configurations.
tofu version
Understanding .terraform.lock.hcl
During initialization, Terraform generated a file named:
.terraform.lock.hcl
This file records:
- Provider versions
- Provider checksums
- Dependency information
Tracking this file in Git ensures that every developer and CI/CD pipeline uses the exact same provider versions.
π‘ Key Takeaways
Day 1 helped me understand that Terraform is much more than a provisioning tool.
The biggest lesson was learning how Infrastructure as Code brings consistency, automation, and version control to infrastructure management. Even with a simple local project, I experienced Terraform's complete lifecycleβfrom initialization to clean destruction of resources.
This foundation will make it much easier to build real cloud infrastructure in the upcoming TerraWeek sessions.
π Project Structure
Day-01/
βββ README.md
βββ example/
βββ images/
β βββ terraform-version.png
β βββ terraform-help.png
β βββ vscode-extension.png
β βββ init.png
β βββ fmt.png
β βββ validate.png
β βββ plan.png
β βββ apply.png
β βββ greeting.png
β βββ destroy.png
β βββ autocomplete.png
β βββ opentofu-version.png
β βββ lock-file.png
π Conclusion
Day 1 laid the foundation for my Terraform journey. I learned why Infrastructure as Code has become an essential DevOps practice, explored Terraform's core concepts, completed my first Terraform workflow, and understood how infrastructure can be managed in a consistent, repeatable, and version-controlled way.
Looking forward to Day 2, where I'll dive deeper into HCL, variables, expressions, and reusable configurations.
π·οΈ Tags
#Terraform #InfrastructureAsCode #DevOps #HashiCorp #OpenTofu #GitHub #CloudComputing #TrainWithShubham #TerraWeekChallenge










Top comments (0)