- TechInsightNeuron
- Posts
- Getting Started with Terraform: CLI, HCL, and Your First Config
Getting Started with Terraform: CLI, HCL, and Your First Config
Install Terraform, understand its CLI, and write your first infrastructure-ready configuration.

👋 Hey there, I’m Dheeraj Choudhary an AI/ML educator, cloud enthusiast, and content creator on a mission to simplify tech for the world.
After years of building on YouTube and LinkedIn, I’ve finally launched TechInsight Neuron a no-fluff, insight-packed newsletter where I break down the latest in AI, Machine Learning, DevOps, and Cloud.
🎯 What to expect: actionable tutorials, tool breakdowns, industry trends, and career insights all crafted for engineers, builders, and the curious.
🧠 If you're someone who learns by doing and wants to stay ahead in the tech game you're in the right place.

Installing Terraform
Terraform runs as a single binary — which means setup is blissfully lightweight. Here’s how to install it on different systems:
🔹 macOS
If you use Homebrew:
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
To confirm it's installed:
terraform -v
🔹 Windows
Download the .zip
from the official site, extract, and add the folder to your system’s PATH from Official Website
🔹 Linux
Download from the Terraform releases page or use:
Download from the Terraform releases page or use:
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install terraform
Exploring the Terraform CLI

Once installed, run:
terraform
You’ll see a list of available commands. Let’s focus on the ones that matter most right now:
Command | What It Does |
---|---|
| Initializes your project (downloads plugins) |
| Shows what Terraform intends to do |
| Actually makes the changes |
| Tears down all the infrastructure |
Each command plays a role in Terraform’s plan → apply → destroy lifecycle.
Understanding .tf
Files and HCL Syntax

Terraform config files end in .tf
. These are written in HCL — a human-friendly, JSON-compatible configuration language designed for clarity.
Here’s what HCL is not:
It’s not a scripting language
It doesn’t run logic or loops like Python
It doesn’t require indentation rules like YAML
Instead, it’s declarative — you tell Terraform what you want, not how to do it.
Here’s an example block:
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "web" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
}
Each block has:
A type (e.g.,
resource
,provider
)A label (e.g.,
aws_instance
,"web"
)A set of arguments (like
ami
,instance_type
)
Your First Terraform Configuration (Safe & Local)

Let’s use a null resource — a Terraform trick that doesn’t create any real infrastructure but lets us test the workflow.
🧱 Step-by-step:
1. Create a working directory:
mkdir terraform-basics && cd terraform-basics
2. Create main.tf
:
terraform {
required_providers {
null = {
source = "hashicorp/null"
version = "~> 3.0"
}
}
}
provider "null" {}
resource "null_resource" "example" {
provisioner "local-exec" {
command = "echo Hello, Terraform!"
}
}
3. Run your first commands:
terraform init
terraform plan
terraform apply
Confirm with yes
and watch the output.
4. To clean up:
terraform destroy
Common Pitfalls / Pro Tips
✅ Always run terraform plan
before apply
— Don’t fly blind.
✅ Keep your .tfstate
file out of Git — It contains sensitive info.
✅ Use version constraints in provider blocks — Prevent breaking changes.
❌ Don’t mix manual and Terraform-created resources in the same cloud environment you’ll confuse Terraform’s state tracking.
💡 Tip of the Day:
Start small and local.
Using the null_resource
is a smart way to learn Terraform’s workflow without touching real infrastructure it’s safe, fast, and gives you the exact same CLI experience you’ll use in production.
📚 Resources & References
1️⃣ Terraform CLI Command Guide
🔗 Documentation
Official list and usage examples of all Terraform CLI commands.
2️⃣ Installing Terraform on All Platforms
🔗 Install Docs
Clean installation walkthroughs for macOS, Windows, and Linux.
3️⃣ HashiCorp Learn: Terraform Basics
🔗 Tutorials
Beginner-friendly CLI practice tutorials with example code.
4️⃣ Terraform GitHub Repository
🔗 Source Code
Dive into the open-source source code of Terraform itself.
5️⃣ Null Provider Explanation
🔗 Module Doc
Use this provider to practice configuration before deploying real infrastructure.
🔗Let’s Stay Connected
📱 Join Our WhatsApp Community
Get early access to AI/ML resources, behind-the-scenes updates, and connect with like-minded learners.
➡️ Join the WhatsApp Group
✅ Follow Me for Daily Tech Insights
➡️ LinkedIN
➡️ YouTube
➡️ X (Twitter)
➡️ Website
Conclusion
You’ve just taken your first real steps with Terraform — not by staring at theory, but by actually setting up the CLI, writing your first .tf
file, and running through the full init → plan → apply → destroy
lifecycle. That simple null resource? It’s more important than it looks. It teaches you the core Terraform workflow — the exact same one you’ll use when provisioning real cloud infrastructure.
Understanding the CLI and HCL at this stage is like learning to walk before you run. You now know how Terraform thinks, how it plans, and how it applies — and that foundation will stay with you even as things get more complex.
In the next blog, we’ll unlock how Terraform interacts with providers and resources the real-world connection between your .tf
code and the infrastructure it builds.
You're ready for it.