Skip to main content

Command Palette

Search for a command to run...

πŸš€ Terraform Series – Day 4

Published
β€’2 min read
πŸš€ Terraform Series – Day 4

Terraform Workflow: init, validate, plan, apply & destroy

🧠 Before Starting (AWS Setup)

Before using Terraform with AWS, we first need to configure AWS access on our local machine.

πŸ‘‰ Steps:

  • Install AWS CLI
  • Configure AWS using:
aws configure

πŸ‘‰ It will ask for:

  • AWS Access Key

  • Secret Key

  • Region

  • Output format

βœ… After this setup, Terraform can interact with your AWS account.

🎯 Objective

  • Understand Terraform workflow

  • Learn core commands

  • Perform hands-on execution

🧱 Step 0: Create Terraform Configuration File

πŸ‘‰ Create a file:

main.tf

πŸ‘‰ This file contains your Terraform infrastructure code

βš™οΈ Step 1: Initialize Terraform

πŸ”Ή Command:

terraform init

πŸ”Ή Purpose:

  • Initializes working directory

  • Downloads required providers

  • Prepares environment

βœ… Step 2: Validate Configuration

πŸ”Ή Command:

terraform validate

πŸ”Ή Purpose:

  • Checks syntax of .tf files

  • Ensures configuration is valid

πŸ‘‰ β€œCheck if your code is correct”

πŸ“Š Step 3: Review Execution Plan

πŸ”Ή Command:

terraform plan

πŸ”Ή Purpose:

  • Shows what Terraform will do

  • Lists resources to create/change/destroy

  • Works as a dry run

πŸ‘‰ β€œPreview before execution”

πŸš€ Step 4: Apply Configuration

πŸ”Ή Command:

terraform apply

πŸ”Ή Purpose:

  • Executes the plan

  • Creates real infrastructure

πŸ‘‰ Type yes to confirm

🧨 Step 5: Destroy Infrastructure

πŸ”Ή Command:

terraform destroy

πŸ”Ή Purpose:

  • Deletes all resources

  • Avoids unnecessary cloud cost

⚑ Auto-Approve Option

terraform apply -auto-approve
terraform destroy -auto-approve

πŸ‘‰ Skips confirmation

πŸ‘‰ Useful in automation (CI/CD)

πŸ‘¨β€πŸ’» About the Author

β€œA complete Terraform series covering everything from fundamentals to advanced real-world infrastructure automation in a DevOps environment.”

πŸ“¬ Let's Stay Connected

Terraform

Part 5 of 8

πŸš€ Terraform Series – Automate Your Infrastructure Starting a complete **Terraform series** where I’ll cover everything from **basic to advanced level** with real-world practicals. In this series, you will learn: β€’ What is Infrastructure as Code (IaC) & why it matters β€’ Terraform fundamentals (providers, resources, state) β€’ Writing and managing Terraform configurations β€’ Variables, outputs & modules β€’ Remote state & state management β€’ Provisioning infrastructure on AWS β€’ Automation & real-world use cases β€’ Advanced concepts like workspaces, modules, and best practices 🎯 Goal: Help you automate infrastructure and become job-ready in DevOps. Perfect for **beginners, students, and DevOps learners** who want hands-on experience. Stay tuned and let’s build infrastructure the smart way βš‘πŸ’» #Terraform #DevOps #Cloud #AWS #InfrastructureAsCode #Automation

Up next

πŸš€ Terraform Series – Day 3

Terraform Blocks, Labels, and Arguments In Day 2, we installed Terraform.Now, before writing real infrastructure code, we must understand how Terraform actually reads and executes configurations. πŸ‘‰ E