Skip to main content

๐Ÿ“˜ Terraform Series โ€“ Day 4

Updated 2 min readMarkdown
Part of seriesTerraform
๐Ÿ“˜  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

About the author

  • Gujjar Apurv is a passionate DevOps Engineer in the making, dedicated to automating infrastructure, streamlining software delivery, and building scalable cloud-native systems. With hands-on experience in tools like AWS, Docker, Kubernetes, Jenkins, Git, and Linux, he thrives at the intersection of development and operations. Driven by curiosity and continuous learning, Apurv shares insights, tutorials, and real-world solutions from his journeyโ€”making complex tech simple and accessible. Whether it's writing YAML, scripting in Python, or deploying on the cloud, he believes in doing it the right way. "Infrastructure is code, but reliability is art."

No comments yet. Be the first to comment.

Terraform

Part 4 of 12

๐Ÿš€ 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 5Terraform Providers, Resource Types & Naming In todayโ€™s Terraform journey, I explored one of the most fundamental concepts that every DevOps engineer must understand Providers and Resource Naming Stru

More from this blog